Managing test data-driven variables

How to work with test data-driven variables in browser and API tests

You can create data-driven variables at the test level as placeholders for variable values that you expect to be passed during a test run. Test data-driven variables are useful in the following situations:

Creating test data-driven variables

When creating data-driven variables, you have to assign a default value to be used in the event that the test doesn't receive that variable value from an external source, such as a DataTable. Default values are also helpful for training tests that rely on variables at runtime, such as environment variables or shared variables from previous tests.

Browser tests

You can create test-data driven variables in the mabl Trainer from the Variables modal:

  1. Click on the {x} button in the bottom toolbar of the mabl Trainer.
  2. Select the option "Manage the variables in this test" to open the Variables modal.
  3. Click on the Data-driven variables button.
1970

The Variables modal

  1. Click on the + New variable button.
  2. Enter a variable name and default value.
1992

Managing test data-driven variables

  1. Click the Apply button to confirm your changes.

API tests

You can create data-driven variables in the API Test Editor by clicking on the Add row button in the Variables panel.

Click here for more information on adding test data-driven variables to API tests.

Using data-driven variables

You can use data-driven variables just like any other variable. For more information on using data-driven variables, check out one of the following resources:

Editing default variable values

On the Test Details page

  1. Click on the Edit variables button in the Data-driven variables section.
  2. Update the default values.
  3. Click Save.
600

Editing data-driven variables from the Test Details page

In the mabl Trainer

For browser tests, you can also update and delete test data-driven variables in the mabl Trainer:

  1. Click on the {x} button in the bottom toolbar of the mabl Trainer.
  2. Select the option "Manage the variables in this test" to open the Variables modal.
  3. Click on the Data-driven variables button to start editing your test data-driven variables.
    • To update, modify the name or value fields.
    • To delete, click on the trash icon. You can also bulk-delete variables by selecting the variable checkbox and clicking the Delete Selected button.
  4. Click on the Apply button to save your changes.

In the API Test Editor

Use the Variables panel in the API Test Editor to update and delete test data-driven variables.

Identify flow data-driven variables

You can distinguish test data-driven variables from flow data-driven variables on the Test Details page in the Data-driven variables section:

  • Flow data-driven variables: If a data-driven variable includes a link to a flow, it means that the variable is a flow data-driven variable. Clicking on the name of the flow takes you to the Flow Details page.
  • Test data-driven variables: If a data-driven variable does not include a link to a flow, then the variable is a test data-driven variable.
600

Editing data-driven variables from the Flow Details page