Using variables in the mabl Trainer
There are many actions in the mabl Trainer that allow for the use of variables:
- Input values
- Visit URL steps
- Assertions
- Flows
- Javascript snippets
- Conditionals
- Configure Find
- Custom finds
- API steps
- Echo steps
Depending on the type of step, you will either select the variable from a dropdown or reference it in a string with mabl variable syntax.
Mabl variable syntax
A variable can be referenced in mabl tests by prepending the variable name with an @ symbol and wrapping it in double curly braces {{ }}.
For example, if you want to reference a variable called "product_id", you can write
{{@product_id}}
Input values
Once a variable is defined, you can use that variable as an input value:
- Click on the "{x}" button.
- Select "Use an existing variable" in the menu that appears.
- Click on the Input value button. (For URL to visit, check out this guide.)
- Select a page element (an input field or textarea) into which the variable's value should be inserted.
- In the mabl Trainer window, choose the variable from the dropdown.

- Click OK. The variable's value will be inserted into the selected input field on the page.
Referencing variables
Using mabl variable syntax, you can combine variables with other variables or static text and use them in input steps, assertions, conditionals, and steps that use additional find criteria (Configure Find and custom find).
Here is an example that updates an existing input step:
- Click on the pencil icon for the input step. A configuration menu will appear where you can update the value.

- Use mabl variable syntax to reference the variable. This example references the variable
new_user
, which has a current value of "user789". In the preview,{{@new_user}}@email.com
appears as[email protected]
.

- Click OK. When you play the step again, it will enter the value shown in the preview.
Here is an example of an assertion that references a variable:

Limitation to referencing variables
Variable interpolation is not supported in data-driven variables or environment variables. This means that their values cannot contain references to another variable, such as
{{@anotherVar}}
.
Updated 7 months ago