Creating and Using Variables

Variables can be created and used in later steps during your tests

Search our documentation:

Toggle Documentation Menu

Creating and Using Variables

Jump to...

Set Variable

One common scenario where this comes up is when we need to generate a unique email address for a signup form, then wish to assert that email address later on.

Storing a unique email into a variable

You can see in the test above that we’re creating a unique email address (using one of our built-in value generators) then storing it in a variable named “email” with the “Set Variable” command. The value in the “email” variable can then be accessed using notation. You can see that we’re assigning it to the email field, submitting the form, then asserting that the email address is present in the display element on the following page.


Extract from Element

This command allows you to extract the contents of value of an element and store it in a variable for use in later steps.

Extracting a value from the DOM into a variable


Extract from JavaScript

This command allows you to return a value from custom client-side JavaScript and store it in a variable for use in later steps.

Extracting a variable from JavaScript

You can also use this functionality, along with JavaScript’s Date functions to create and use custom date strings in your test. This example will return the current date in YYYY-MM-DD format.

Storing a date into a variable


Built-in Variables

You may find that you need to generate a unique value each time a test is run. For instance, you may need to create a new email address each time you test your website’s signup form. We provide two built-in variables so that numeric timestamps and random alphanumeric strings can be generated within a step.

Available Built-in Variables

{{TIMESTAMP}}
This will generate a numeric timestamp
{{ALPHANUMERIC}}
This will generate a random 16 character alphanumeric string

So for instance, instead of assigning test@domain.com as the email address in your form, you can use test+{{TIMESTAMP}}@domain.com to generate a unique email address with each test. If you are looking to use the generated email address in various steps, we suggest using the “Set Variable” command to place it into a variable, which can then be reused in multiple steps.


Suite-level Variables

Variables can be defined at the suite level under Settings > Variables. These variables are available within all tests in the suite when they are run.

Set suite-level variables


Variables via Application Execution

You can also easily set variables on the fly when triggering tests or suites in our application using the "Run with Custom Settings..." option accessible in the "More" dropdown menu at the top of the page.

Run test with custom settings


Variables via API Execution

Variables can be passed into your test or suite runs as simple GET paramaters when you execute via the API. See our API documentation for details.