Variables let you capture dynamic information at run‑time and reference it later from a single, well‑known location.
Using variables keeps your scenarios concise and resilient – you change the value in one place and every reference stays up to date.
Open Test Data Variables
Open Test Data ▸ Variables in the left‑hand navigation.
Add a new variable
Click + Add Variable, give it a name and value, then save.
Mark as sensitive (optional)
Toggle Sensitive to hide the value after creation.
Tip: Because project variables are encrypted at rest you can safely store secrets such as API keys, passwords, or tokens.
You can add a Define variable step anywhere in a test. Stably offers four ways to assign a value:
Type any literal such as 3
, true
, or "hello world"
and click Save.
When defining the variable value, select the “AI Extraction” option and simply type in a natural language description of the data you want to extract, and Stably will capture its text/attribute in real‑time. In the example below we store the large centered number in var1
:
In case you don’t need a very particular value, but something random that satisfies a set of criteria, then use AI to generate appropriate random values – e.g. “Generate a phone number ending in 6363”. Stably creates realistic, unique data every run.
Use JavaScript ande any built-in helpers to combine or transform existing variables (prefix VARS.
) to come up with the value that will be assigned to this new variable
Stably also allows you to extract information from emails that are sent to you Stably-provisioned email address. For more details on how to do this, check out this document on “Receiving Emails”
There are several ways to utilize variables throughout your tests. Note that all variables (both global and local) are referenced from the same VARS
object
Use VARS.<name>
to refer to the variable with name <name>
. VARS
is a JS object so you can use it like how you would any other JS object.
Similarly, when filling out text inputs, you can reference your variables in the same way to fill the input with variable’s value rather than a static literal.
Whenever you ask Stably’s AI to generate steps it automatically receives the current variable set, so you can prompt it with instructions like “if VARS.plan
is ‘premium’ skip the upsell page”.
Variables are also supplied to the AI when asserting, so you can add a layer of conditional logic to your AI visual assertions.
✔️ Do | ❌ Avoid |
---|---|
Give variables descriptive, lower‑camelCase names (totalRevenueToday ). | Abbreviations that will be hard to remember later (trtd ). |
Store secrets in project variables marked Sensitive. | Hard‑coding credentials directly in steps. |
Re‑use variables instead of duplicating text across steps. | Updating the same literal value in many places. |
Reset or regenerate variables at the start of each run when needed. | Relying on state left over from previous runs. |