Tests
Test Variables
Capture and reuse values inside SmoothDeploy tests and scripts
Variables let you pass dynamic data between steps, reuse project defaults, and build richer assertions without hard-coding values.
Variable sources
- Project variables: Defined at project level for environment URLs and shared configuration.
- Test variables: Added in the test editor as a JSON object; these override project values with the same key.
- Runtime variables: Steps such as Extract text, Extract cookie, Generate date, and Generate string push new keys into the variable bag while the test runs.
Referencing variables in steps
Fields that use the reference picker (e.g. Fill, Assert, Fetch) accept {{vars.key}}. Choose Variables in the picker to insert the token, or type it manually.
{{vars.orderId}}At execution time SmoothDeploy resolves the token using the merged variable map (project → test → runtime). In generated Playwright code the placeholder becomes a lookup on the _VARS object:
await page.getByTestId('order-number').fill(_VARS["orderId"]);Extraction and generator actions update the same object. For example, an Extract text step saves the captured value before subsequent steps run:
_VARS["confirmationCode"] = await page.locator('[data-id="code"]').textContent();Best practices
- Establish naming conventions (e.g.
customerId,latestInvoice) to avoid clashes across shared steps. - Scope variables carefully; prefer extracting right before use instead of relying on distant steps.
- Combine with parameters by writing selectors or assertions like
{{vars.customerId}}and{{params.plan}}in the same step. - Use the JSON editor in Test details → Variables to seed defaults, then let extraction steps overwrite individual keys when needed.
Troubleshooting
- If a token renders blank, confirm a prior step actually sets the variable (check run logs or previewed Playwright script).
- Nested objects are supported, but reference them with dot syntax (
{{vars.address.city}}). - Avoid storing secrets in variables; use
{{secrets.key}}for sensitive values so they remain outside saved test definitions.