Reflect Docs

Variables

Configure input values to be dynamically generated or define static values that can be overridden for use in data-driven testing scenarios.

When to Use a Variable

Variables allow you to define input values which can either change on every test run based on your specifications, or be set to a static value that you can override when you run a test. Here’s a few examples of when a variable comes in handy:

  1. Testing Your Registration Flow: Being able to register a user is often one of the most important end-to-end tests you can create. However there’s one big challenge with creating automated tests for this flow: once you’ve registered an email address/username in your system, you can’t register it again. By associating a variable to the username / email address in your test, and assigning it a dynamically generated value, you can ensure that your test registers a new user every time it runs.

  2. Data-Driven Testing: Setting an input value to a variable with a static value allows you to override that value in future test runs. This enables data-driven testing scenarios where you pass in different input values on every test run.

Defining A Variable

To define a variable, create a recording or view an existing recording and select the Input step that you’d like to associate with a variable. After selecting the Input step, you’ll see a Use Variable button in the Detail view:

Clicking on this button will open a modal which lists all of the variables you’ve previously created, along with a form that lets you add a new variable:

Either select an existing variable or add a new variable and then select it, then click the Select Variable button to associate it with your Input step.

Dynamic Values

To generate a dynamic value for a given variable, include the alpha, num, or alphanum function in your variable definition. Each of these functions outputs a series of random letters and/or numbers equal in length to the number passed into the function.

Examples:

Definition Example Value
user+${alpha(10)}@example.com user+akfboaqbop@example.com
pass${alpha(5)} passboiqg
${alphanum(8)} oq2ki16n
Call me, ${num(10)} Call me, 0149783430
Copyright © 2020 Reflect Software LLC. All Rights Reserved.