Variables are an essential step to creating robust, flexible tests. From extracting text from a page to sharing variables across tests, mabl offers a variety of variable types to help you meet your testing goals.
This article describes the different types of variables in mabl:
- Application URLs
- Environment variables
- Credentials
- Test-generated variables
- Local variables
- Run-time variables
- Data-driven variables
Application variables
Application variables contain information about the application under test, such as the starting URL or the mobile build file. They are assigned at the beginning of a test based on where the application is deployed.
The following table lists application variables by test type:
Test type | Variable(s) | Description |
Browser | app.url |
The starting URL of the application under test. Also known as the web application URL. |
API | api.url |
The base URL of the API under test. Also known as the API URL. |
Mobile |
|
The name and version of the mobile build file. |
You can create and manage application variables in the Configuration section:
-
Configuration > Applications: create and manage
app.url
andapi.url
variables. -
Configuration > Mobile build files: create and manage
app.build_name
andapp.build_version
.
Typically, application variables are configured in the plan(s) that contains the test or selected at the beginning of a training session.
Environment variables
Environment variables become available whenever a test is run against an environment. Environment variables are encrypted with a workspace-specific encryption key.
Environment variables are commonly used for API keys.
You can create and manage environment variables in the Configuration section: Configuration > Applications.
Credentials
mabl credentials are used for authentication scenarios. Just like environment variables, mabl credentials are encrypted with a customer-specific encryption key before getting added to our database.
The following table lists credentials by test type:
Test type(s) | Variables |
Browser and mobile |
app.defaults.username and app.defaults.password
|
API |
api.credentials.username and api.credentials.password
|
To create and manage credentials, go to the credentials page: Configuration > Credentials.
Test-generated variables
A test-generated variable is a variable whose value is dynamically created during test execution. You can create test-generated variables from a value on the page, an API response, JavaScript output, cookie data, database queries, and valid expressions.
For more information on test-generated variables, check out the following articles:
Local variables
Local variables include flow parameters and snippet parameters. They exist within the scope of the flow or snippet from which they are declared.
Flow parameters are prepended with flow.
. For example, the flow parameter productId
becomes flow.productId
.
Runtime variables
Runtime variables have values that are generated at runtime. These variables capture real-time data and the context of the current testing environment.
Examples of runtime variables include:
-
app.test_run_id
: the unique identifier for the current test run -
run.loop_index
: the index of the current iteration of a loop.
Mobile tests have a special set of runtime variables:
-
device.model
: the model of the device -
device.height
: the height of the device -
device.width
: the width of the device -
os.version
: the OS version of the device -
os.api_level
: the API level of the device - only applicable for Android devices
Data-driven variables
A data-driven variable is a variable whose value is supplied to the test at runtime from a different source.
Examples of data-driven variables include variable values associated with a DataTable scenario and shared variables exported from another test in the same plan.
Learn more
Learn more about working with variables: