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.
- Select "Create a new variable" from the menu. A new screen will appear where you can select a variable source and assign a name.
- Choose a variable source. At present, you can generate variabltes from the following sources:
- String template
- Element properties
- Custom JavaScript code
- Mabl mailbox address
- A data source (data-driven variable)
- Assign a name
- Click OK.
After clicking OK, a new step will appear 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 two other ways to create variables in the Trainer:
- API steps: extracting the response into a variable.
{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
The mabl string template can be used to create strings from constant values, other variables, random values, and/or mathematical expressions. For more information on supported expressions, check out the Valid expressions guide.

Element property
Element property variables can be used to 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 value using" selector.
- Click the mouse icon.
- Select an element on the page.
- From the Property selector, choose what element property you would like 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.

Custom JavaScript variables
Custom JavaScript snippets can be used to generate a variable value. For more details on writing JavaScript snippets, check out this guide. The output of the snippet will be displayed in the shaded Results box.

Mabl mailbox address
By setting the source to "mabl mailbox address", you can generate an email address that can be used for further email testing. See our guide on Email testing and validation for more information.
Data source
Selecting "data source" creates a test data-driven variable. For more information on this variable source and how to use it, check out our guide on test data-driven variables.
Converting test-generated variables into data-driven variables
If you decide to use shared variables or a DataTable, and you want to convert existing variables into data-driven variables, you can do so in four steps:
- Click on the pencil icon of the create-variable step(s) that you would like to convert.
- Change the source to "data source."
- Enter a default value.
- Click OK.
Two things will happen when you do convert the variable:
- The create-variable step will be removed from the test steps in the Trainer window.
- The variable will appear with its current value in the list of data-driven variables shown in the Manage Data-Driven Variables tab.
Updated about 17 hours ago