Creating variables in the mabl Trainer

To add a variable in a browser test, open the mabl Trainer and take the following steps:

  1. Click on the {x} button at the bottom of the Trainer window.

The variables button

  1. Select "Create a new variable" from the menu.
  2. In the variable creation menu, choose a variable source. At present, you can generate variables from the following sources:
  3. Assign a name
  4. 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:

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:

  1. Select Element property from the "Set variable using" selector.
  2. Click the mouse icon.
  3. Select an element on the page.
  4. From the Property selector, choose what element property you want to set the variable to, such as innerText, class, or tagName.
  5. Assign the variable a name.
  6. 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.