Creating variables in the mabl Trainer
To add a variable in a browser test, open the mabl Trainer and take the following steps:
- Click on the
{x}
button at the bottom of the Trainer window.

The variables button
- Select "Create a new variable" from the menu.
- In the variable creation menu, choose a variable source. At present, you can generate variables from the following sources:
- Assign a name
- Click OK.
After clicking OK, a new step appears in the Trainer window. An exception is made for data source variables. Data-driven variables do not create a new test step.
Other ways to create variables
There are three other ways to create variables in the Trainer:
- API steps: extracting the response into a variable.
- Custom find steps using CSS or XPath
{x} > Manage the variables in this test
: In the Variables modal, click on the Data-driven variables button. You can add test data-driven variables here. Adding a variable in this manner does not create a new test step.
String template
You can use string template variables to create strings from constant values, other variables, random values, or mathematical expressions. For more information on supported expressions, check out the Valid expressions guide.

Creating a string template variable
Element property
Element property variables extract a property from an element on the page and store it in a variable. To create an element property variable, follow the steps below:
- Select Element property from the "Set variable using" selector.
- Click the mouse icon.
- Select an element on the page.
- From the Property selector, choose what element property you want to set the variable to, such as innerText, class, or tagName.
- Assign the variable a name.
- Click the OK button to store your Element property variable.

Creating a variable from element property
Custom JavaScript variables
You can generate variable values from custom JavaScript snippets. For more details on writing JavaScript snippets, check out this guide. The output of the snippet is displayed in the Results box.

Creating a variable from a JavaScript snippet
Mabl mailbox address
By setting the source to "mabl mailbox address", you can generate an email address to use for further email testing. See our guide on Email testing and validation for more information.
Updated 7 months ago