Test variables

A test variable is a user-defined, name-value pair that stores and refers to information throughout a test. You can assign the value of a variable to a test element or assign the value of a UI object property to a test variable.

When you record a test, the URL of the application is stored in the default variable, APP_APP1_URL. You can create variables by using the following options:
  • By using the Add option in the Configure settings and data pane.
  • By using the Add new variable option when you assign the property of an object to a variable in the Assign step.
  • By adding var_name: var_value under vars: section in the Code view of the test script in Test Editor.
You can use the variables for substitution. To substitute data from a test variable, you can use the Details section of the step details pane. You can perform the following actions with test variables:
  • Provide a default value to the variable during variable creation.
  • Change the value of a UI object by replacing the value with a variable. The UI object assumes the value of the variable when the test is run.
  • Change the value of the variable using the 'Assign' statement. You can assign an object property to a variable.
  • Modify the value of a variable by using the values extracted through RegEx patterns.

Types of variables

Variables are classified as input, local, or output variables based on their purpose and scope.

  • Input variables : Provide a way to receive values from calling tests or configurations. Use them to pass data into a test or module at runtime.
  • Local variables : Define values that are used within a test or a suite. These variables remain internal and are not accessible outside the test or suite in which they are declared.
  • Output variables : These variables are used to return values to the calling test or a suite. You can map these variables to existing or new variables to capture the returned data.

Variable state and promotion

Automated test recordings often contain sensitive information, such as passwords, personally identifiable information (PII), security keys, and authentication tokens. You can protect sensitive data by promoting a variable to an environment and marking the variable as a secret. When you promote a variable to an environment, you can mark it as a secret or a standard value. Promoting a variable as a secret automatically masks the value in functional reports, and execution output, ensuring that sensitive credentials remain secure across different application-under-test (AUT) environments. Also, when you promote a variable as a secret, in the configuration settings, the value field becomes blank and it displays a placeholder text 'Enter Value'. You can edit the value of secrets which are displayed as masked values from the Security page. The other standard promoted variables of type Value are used to reuse non-sensitive parameters that can be updated through the environments.

Each variable in the table includes a state indicator that helps you identify how the variable is used at run time.

Random number generation

You can generate random numbers and assign the value to a variable by defining a random expression. For example, you can define ${Math.floor(Math.random()*100)} and assign it to a variable, ${value}.

You can use a random expression in the following ways:
  • Create a new variable in the Configure settings and data step, and assign the random expression to the variable.
  • Create a new variable in the test, and insert an Assign step before any step where the random number is needed. Then, in the Assign step details, you can assign the random expression to the variable.
Assigning the random expression to the variable allows the random number to be stored in the variable and referenced throughout the test run.