Variables

Variables

In testRigor, variables allow users to parameterize values, work with dynamically generated information, or pull test data from a global bank of variables in testRigor. To use a variable in a command, add stored value or saved value before the variable in double quotation marks.

save value "James" as "name"
enter stored value "name" into "First Name"

Variable Hierarchy

Variables follow a hierarchy that determines which value is used when multiple variables share the same name:
Script-generated > Data Set > Global > Built-in

If you have two variables named username:
Global variable: username = “John”
Script-generated variable: username = “Eric”

Since script-generated variables have higher precedence, username will resolve to “Eric”.

Built-in variables

testRigor has built-in variables that users can access for things like the current date and time, the base url, and the username and password (given the username and password have been saved in settings), among others. Built-in variables do not overwrite any other variable.

Global variables

Global variables must be uploaded into the test data storage bank in testRigor by the user. These can be in the form of text, hidden strings, files, and multiline strings. In order of priority, global variables overwrite built-in variables. Read more about global variables here.

Data Sets

Data sets have two main uses in testRigor. First, it allows users to test the same scenarios multiple times simultaneously using different parameters or test data. Some users do not need to test simultaneously, but rather swap out entire sets of global variables in order to test scenarios on environments with slight differences. This is easy to do now that testRigor allows users to link/unlink multiple or all test cases to a data set.

Data sets can be created manually or by uploading a csv file as explained in this document and can also be in the same forms as global variables. In terms of hierarchy, data sets overwrite global variables and built-in variables.

Script-generated variables

Variables saved by a command in the script are the most dynamic type and overwrite variables of all other origins. They can be generated in the script in the following ways.
Some of the most common ways to create script-generated variables include:

Other commands can also generate or save variables, including:

Parameters

You can concatenate variables with other variables or variables with static strings in most commands by adding from the string with parameters or from the string with escaped parameters. ${variable} allows you to insert a saved variable into a larger string.
check that page contains the string with parameters "Welcome, ${firstName} ${lastName}!"
enter from the string with parameters "${homePrefix}/my/path" into "urlPath"
Generate unique date and time with unique parameters either by regex or symbols.
generate from template by string with escaped parameters "${nowDateTimeIso}-**********", then enter into "Data" and save as "generatedData"
Multiple files upload can be done like so:
enter from the string with parameters text starting from next line and ending with [END]
${file_var_one}
<FILE_URL>
[END] into file input "myFileInput"
In the case of identical syntax, a defined rule always has higher priority than general syntax.
You can combine static text with variables, for example:
Fill in the form:
generate unique name, then enter into "First Name" and save as "firstName"
generate unique name, then enter into "Last Name" and save as "lastName"
Then, on the next page, perform a validation:
check that page contains the string with parameters "Welcome, ${firstName} ${lastName}!"

Grabbing values from the UI using AI

AI can be used to extract values from the UI based on a description you provide for the target element.
Example:

grab value by description "10-digit phone number" using AI and save it as "phoneNumber"

Here, 10-digit phone number is the prompt given to AI. AI locates the element that best matches the description and retrieves its value.
If you want to limit the search to a specific section of the UI rather than scanning the entire page, you can include the element or area name in the command.
Example:

grab value by description "10-digit phone number" from "Contact form" using AI and save it as "phoneNumber"

This is useful when the same value type appears multiple times on the page. In this case, AI will only grab the 10-digit phone number that is inside the Contact form.

Reusable Rules

When a reusable rule has the same syntax as a built-in testRigor command, the rule takes priority.
For example, generate from template is recognized by testRigor. If we create a reusable rule also called generate from template , testRigor will use our rule instead.

Reusable-rule priority: which command/rule gets executed when syntax overlaps.

We’ll cover reusable rules in more detail later, so for now, just keep in mind that they take priority over built-in commands.

Test your knowledge

generate by template "${nowDateTimeIso}-", and save in "Data"
generate time using template "${nowDateTimeIso}-" and store as "Data"
generate from template by string with escaped parameters "${nowDateTimeIso}-", then enter into "Data" and save as "generatedData"
template "${nowDateTimeIso}-" to generate and save as "Data"
input multi-files using "${file_var_one}" to "myFileInput"
use "${file_var_one}" and "<FILE_URL>" and load to "myFileInput"
enter from the string with parameters text starting from next line and ending with [END]
${file_var_one}
<FILE_URL> [END] into file input "myFileInput"
upload multiple "${file_var_one}" and "<FILE_URL>" to "myFileInput"
generate unique email, then enter into "Your Email" and save as "emailID"
generate unique name, then enter into "First Name" and save as "firstName"
generate email, then enter and save as "Your Email"
generate unique emailID, then enter into "Your Email" and save as "emailID"
To perform the save action
To find the element that matches the description and retrieve its value
To validate the phone number format after retrieval
To highlight the element on the UI