Variables
Minimize hardcoding to reuse test data across multiple steps
Variables are useful when a value input during test recording needs to be reused later within the same test. It helps in:
- Eliminating hardcoded values
- Maintaining tests easily. You can update the variable at one place rather than modifying it across multiple test steps.
- Making tests more readable and self-explanatory by assigning meaningful names.
When to use variables?
- Use variables when dealing with repeated static values across different steps within a test. For example:
- Validate full name or email in accounts profile section after logging in
- Validate pricing details on checkout page after selecting a particular plan
-
When the test requires dynamic input that may change during each test run which has to be consumed at a later point in the test.
- Use variables to centralize and manage data to make tests easier to update and maintain.
How to create and use a variable?
There are four ways to create variables:
- Define static variables for test steps: Create a variable at any step where you have to input values.
- Extract value from website dynamically: Capture dynamic values from website UI and store them as variables for later use.
- Create variables using Custom JS script: Use javascript snippet to create variable from more advanced workflows. Learn more.
- Extract value from API response: Store the response details from API step into a variable for later use. Learn more.
You can reuse these variables anytime you need to input values or perform text validation.
Define variables for test steps
- Navigate to the step where you have an input value which has to be reused.
- Click on the step name or the “>” icon to open the step configuration details.
- Click on “Convert to variable” below the text input.
- Give a unique meaningful name to the variable and save it.
Extract value from website dynamically
In test automation, there could be scenarios where you would want to store some text content on the UI which dynamically changes into a variable. The Extract Value feature lets you capture these dynamic values from screen elements, store them as variables and reuse them in your test. For example, you can capture the price_of_product
and store it in a variable to validate in checkout page if the total cost equals price_of_product
* quantity
. Since the price_of_product
may change, extract value lets you use the updated values for a reliable test execution.
Perform the following steps to capture dynamic values from screen elements during test execution:
- In the recorder, click the Ellipsis icon and select Extract Value.
- Hover over the screen and select the element to create variable.
- Assign a name to the variable and click Create.
Importing a variable
- Navigate to the step where you want to reuse the variable created.
- Click on the step name or the “>” icon to open the step configuration details.
- Click on “+” and select “Import a variable” if the step is an input step or click “{}” icon besides the text input if the step is a text validation step.
- Import variable in Input step
- Import variable in Text validation step
- Select the relevant variable you want to import.
Managing a variable
-
Managing a variable is possible at any step where the variable is in use. You can navigate to the step configuration details and edit the variable to any value of your choice.
-
Additionally, Low Code Automation also allows you to manage your variables from a single configuration page where you can edit any variable value and delete any variable that is not in use. Click on the “⚙” icon to access the page.
- A variable can only be deleted when it is not used in any other steps.
- A variable can not have a variable within it.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!