Environments: pre-defining variables and browsers

In Frontend Robot you can define a variable during a test with the Assign Variable instruction or pre-define a set of variables to apply to all tests in a suite. This is done in a test Environment.

What’s a test Environment?

In Frontend Robot, an Environment defines two aspects of a test:

  • The browsers the test will run on
  • A set of variable definitions to apply during the test

Environments are completely optional. A test suite with no environments will run on the latest version of Chrome without any pre-defined variable.

Common use case: change the starting URL of a test

A common use case for Environments is to replace the starting URL of a test. You can, for example, use the variable ${productUrl} in the initial Go To URL instruction. This way you can run the same test on staging or production by simply creating two test environments; one assigning the staging URL to the ${productUrl} variable the other assigning the production URL to the same variable:

Using variables
Using a variable in a `Go to URL` field

Defining variables in an environment

We define the value of a variable within a test Environment. To create an environment, go the the Environments tab in the test suite view, then click on New Environment.

Create a new environment
Create a new environment

Now we can define our variables. Set the name of the variable, then the value and click Add.

Create a new environment
Create a new environment

A test environment applies to an entire test suite therefore you can use the same variable across multiple tests in the same suite.

Running a test suite within an environment

To apply the variable values specified in an environment, we have to run the test suite within that environment.

Once you create an environment, you will see its status in the Results tab of the test suite view. Running the suite in that environment is as easy as clicking on the Play button in the environment box as shown below:

Run environment
Run environment

Once you create the first environment for a test suite, you won’t be able to run the suite outside of an environment anymore, unless you delete all the environments.

Running a single test within an environment

Instead of running an entire test suite, you may want to run a single test within an environment. Do do that, go edit the test then select the environment from the dropdown in the toolbar - as shown in the screenshot below - then click Run.

Run environment
Run environment

Questions?

We're always happy to help with test creation or other questions you might have! Search our documentation, contact support by email or on chat, or connect with our sales team.