Accessing data

All steps has access to the following variables:

  • env: An object containing any configured environment variables, as well as any dynamic variables set through setVariable during the test. The following variables are automatically set in the env object:
    • BASE_URL : the starting URL of the test.
    • CURRENT_URL : the current URL of the active page. This is updated after every step.

In a module

Modules can read and write to the overall test context. When editing a module, you can also add inputs to the module definition. This can be useful when you need to test similar scenarios with different inputs.

Inputs are added to the environment when the module step is executed at a key you choose. You can access them through the env variable in JavaScript steps and within {{ }} templates, such as {{ env.INPUT_NAME}}.

Updating data

All steps support a “Save to environment” option that can be used to save the result of the step to the environment to a particular key. Note that many steps do not return any data or only return data under certain circumstances (for example, click actions only return a result when a download is triggered).

You can also use the special setVariable function within JavaScript steps to modify the env global object programmatically. Non-serializable values such as functions and circular objects will be rejected.

The function signature of setVariable function is as follows:

function setVariable(name: string, value: unknown);

Was this page helpful?