Variables

Variables help address testing scenarios that require dynamic values. They also help with passing values to, from and in-between tests so you can keep your tests shorter and easier to troubleshoot and maintain.

Use cases

Variables overview

Variables in mabl come in a few different categories:

Type

Description

Example

Application URL

Application URLs are created and managed in the Configuration section.

This variable holds the starting URL of the application, and is assigned at the beginning of the test based on where the application is deployed. It is typically configured in the plan(s) that contains the test or selected at the beginning of a training session.

app.url (in browser tests)
api.url (in API tests)

Environment variables

Environment variables* are set in the Configuration section and become available whenever a test is run against an environment.

Commonly used for API keys

Credentials

Credential sets* can be created in the Configuration section and are assigned to tests and plans at training and runtime.

username: app.defaults.username;
password: app.defaults.password

Test-generated variables

These variables are created by a test step, using Create variable (excluding "Data Source"), an API step, or mabl Mailbox.

Creating a random value

Local variables

Local variables include flow parameters and snippet parameters, and they exist within the scope of the flow or snippet from which they are declared.

flow.productId
flow.quantity

Runtime variables

Variables whose values are generated at runtime, such as the test run ID and loop index (during a loop).

run.loop_index

Data-driven variables

User-defined variables that get their values before a test or flow starts running.

  • Configuring a test to receive shared variables in a plan run.
  • Running a test through a set of scenarios defined in a DataTable

*Credentials and environment variables are encrypted.

Managing variables in the mabl Trainer

If you need to view or update variables while you are training a test, take the following steps:

  1. Click on the {x} variable button at the bottom of the Trainer window
  2. Select "Manage the variables in this test" to open the Variables modal.
1970

The Variables modal

From the Variables modal, you can manage all the variables in your test in a table:

  • Name: this column shows the names of the variables available in the test.
  • Initial value: this column shows values of the variables and their variable source.
  • Current value: in the Current value field, you may update the variable value in the current training session. Override values in the Current value field do not persist when the test is saved.

📘

Note on test-generated variables

Test-generated variables, which are variables created by a test step, do not have an initial value. If a test-generated variable’s value is created from JavaScript, element extraction, mabl mailbox, or an API step, the Variables modal shows [not yet evaluated] for the current value until the step executes in the mabl Trainer.

Data-driven variables

Click on the Data-driven variables button to add, edit, or delete test data-driven variables.

Session configuration

Click on the Session configuration button to make changes to the test's configuration during the training session, including application, environment, credentials, and DataTable scenarios. These are the same settings that you select when you edit an existing test in the Trainer.

See all variables in a cloud run

If you want to review the variables from a test run, take the following steps:

  1. Navigate to the Test Output page.
  2. Click on View all >. A Test Details modal will appear.
  3. Click on the link to View variables.
600

The Test Variables modal shows initial and final variable values for a test run and indicates whether any variables were shared.

Learn more

To start creating and using variables in your workspace, take a look at the following guides: