Skip to main content

Store and Reuse Data Across Your Tests

Variables let you capture, store, and reuse information throughout your test flow. Perfect for handling dynamic data like order IDs, user credentials, or any values that change between test runs.

Environment Variables

Set up global variables that work across all your tests. Head to your environment settings and define key-value pairs that your tests can access anywhere. Access them in any step using {{ VARIABLE_NAME }}. They’re available everywhere—in click, type, assertions, JavaScript code, you name it.

Setting Variables On The Fly

From JavaScript Steps

Drop values into variables using window.setVariable():
// Store a generated email
window.setVariable("USERNAME", "user_" + Date.now());

// Save extracted data
const orderNum = document.querySelector('.order-id').textContent;
window.setVariable("ORDER_ID", orderNum);

// Create random test data
window.setVariable("PASSWORD", Math.random().toString(36).slice(2, 15));

From Extract and Save Steps

When using AI Extract or other steps that return values, save the output directly to a variable. Just specify the variable name in the step settings—no code needed. Extract and Save step interface Extract “total price” → Save as CHECKOUT_TOTAL → Use {{ CHECKOUT_TOTAL }} anywhere.

Using Your Variables

Once set, variables work everywhere. In click, type, and other step types, use the template syntax {{ USERNAME }} and it fills in the actual value. In assertions, check if something equals {{ ORDER_ID }}. In JavaScript, use getVariable().
// Get variables in JavaScript using getVariable()
const user = await getVariable('USERNAME');
const orderId = await getVariable('ORDER_ID');

// Or use templates in any input field
"Welcome back, {{ USERNAME }}!"

How Scope Works

Variables live at the test level—set them once, use them anywhere in that test run. Each test execution gets its own fresh set of variables, so parallel runs never interfere with each other. The flow is simple:
  1. Test starts with environment variables loaded
  2. Steps can create or update variables as they run
  3. Later steps access any variables set earlier
  4. Test ends, variables reset for the next run
No complex scoping rules. No variable collisions. Just straightforward data storage that works exactly how you’d expect.
I