- Docs
- Reference
- Step reference
- Waits, conditions and templates
Waits, conditions and templates
Steps run from top to bottom. This page covers the tools that change that: waiting for the app, running a block only when a condition is true, and reusing a sequence of steps from another test case.
In short
On this page you can
- Pause the run for a fixed time with Wait (seconds).
- Wait for an element or a text on mobile and desktop with the Wait For… actions.
- Run steps only when a condition is true, with an IF … END block.
- Reuse a login or setup sequence as one Template step.
- Work out how long a step waits before it fails.
How to use it
- Save the value your condition needs with a Get, API or Database step.
- Add a Python step, set Select an option to IF and write the condition.
- Add the steps of the branch, then a Python step set to ELSE or END.
- For reuse, mark a test case as a template, then add it with Template.
- Run a Dry Run and read the [IF] Condition evaluated line.
Waits#
Most steps already wait: an element step waits for its element, a Visibility Check retries for up to 8 seconds, mail and Kafka steps poll until their timeout. Add an explicit wait only when nothing else waits for the state you need.
| Step | Project types | Waits until | Value |
|---|---|---|---|
| Wait (seconds) | All | The time has passed | 0.1–3600 seconds, decimals allowed, or a variable |
| Wait For Element | MOBILE, DESKTOP | The element exists | None (uses the action’s locator) |
| Wait For Visible | MOBILE, DESKTOP | The element is visible | None |
| Wait For Text | MOBILE | A text appears in the element | The text |
| Wait (desktop) | DESKTOP | The time has passed | Seconds |
| Wait for Mail | All | A matching email arrives | Filters and timeout |
| Network Check | WEB | The matching browser call completes | URL and timeout, 1–120 s |
Wait (seconds) messages: Waited 2 seconds on success. Errors: “no wait time given, enter the number of seconds”, “"abc" is not a valid number of seconds”, “5000 s is out of the allowed range (0.1 - 3600 s)”, “variable {{tc:x}} could not be resolved”.
Prefer waits that end early
A fixed wait always costs its full time and still fails when the app is slower than usual. On the web, a check that waits (Visibility Check, Network Check) or the element step itself is usually enough.
How long a step waits for its element#
Two project settings control waiting. Both are in the project’s settings:
- Wait Timeout (sec): how long a step waits for its element. Default 30, allowed 1–120.
- Page Load Timeout (sec): how long a page may take to load. Default 120, allowed 1–120.
An element step makes up to 3 attempts. The first attempt uses the full Wait Timeout. The two retries use 4 seconds each, after a 2-second pause. Only then does auto-heal start.
time ≈ Wait Timeout + 2 × (2 s pause + 4 s retry) + iframe search (up to 8 s)
With the default Wait Timeout of 30 s: 30 + 2 × (2 + 4) = 42 s, plus up to 8 s of iframe search, so about 42 to 50 seconds before the step reports the element as not found or auto-heal takes over. With a Wait Timeout of 10 s it is 10 + 12 = 22 to 30 seconds.
- The per-step Timeout parameter (1–300 seconds) works only on Get-family steps (web Get, mobile and desktop Get Text, Get Attribute, Store Variable). On other steps it has no effect.
- On mobile, each step has a time budget of Wait Timeout + 10 seconds; an AI step gets 35 seconds more.
- A pipeline can retry failed test cases (Retry Count in Schedule). A Dry Run never retries.
Run steps only when a condition is true#
Conditions are Python steps with a control type. The dropdown Select an option on a Python step offers Python (plain code), IF, ELIF, ELSE and END. WHILE and FOREACH are listed with a Coming soon chip and cannot be picked: loops are not available yet. Conditions work in web, mobile and desktop projects.
Save the value to test
For example, a Get step saves the number of orders into
orderCount.Add the IF step
Click Python. In the right panel set Select an option to IF and write the condition as a Python expression:
int({{tc:orderCount}}) > 0.Add the branch
Add the steps that should run when the condition is true, for example Click
Details.Add ELSE (optional) and END
Add a Python step set to ELSE and the steps for the other case, for example Click
New Order. Close the block with a Python step set to END.Steps between IF and ELSE run only when the condition is true; steps between ELSE and END only when it is false.
1 Template Login
2 Get Order count key: orderCount
3 Python IF int({{tc:orderCount}}) > 0
4 Click Details
5 Python ELSE
6 Click New Order
7 Python END- Compare numbers as numbers. A variable is replaced by its text. Wrap it:
int(…), orfloat(…)for decimals. Without it,"5" > 10raises an error. - ELIF adds another condition, checked only when the conditions above it were false.
- Each IF, ELIF and ELSE step writes its own line to the log, for example
[IF] Condition evaluatedwith the condition, the resolved values andTRUE → branch body executedorFALSE → moved to ELSE branch. - If the condition raises an error, the line is
[IF] Condition could not be evaluatedwith a hint (“use int(...) / float(...) for numeric comparisons”) and the step fails. - If an IF has no END, or its condition is empty or not valid Python, the run does not start at all: “The test could not start — a step's code or IF/ELSE/END structure is invalid…”. See Troubleshooting.
An IF, ELIF, ELSE or END step has no output variable; only a plain Python step does. More on Python code in Code steps.
Template steps#
A template is a test case you reuse inside other test cases, for example Login or Create customer. In the calling test case it is one step; when the case runs, the template’s steps run in its place.
Make a template
Open the test case to reuse. Click the kind chip in its header, choose Template and save.
Add it to another case
In the other test case click Template. The dialog Template Test Cases lists the project’s templates. The current case and templates that already call it are left out, so you cannot build a loop. Click a template to add it.
Check what it does
Select the template step. The right panel shows what it does, the variables it reads and the variables it produces, and links to open the template.
- Live reference. Editing the template changes every test case that uses it, from the next run on.
- Variables flow through. Variables saved inside the template (a token, a user ID) are available to the steps after it.
- Inactive steps inside the template are left out, as in any test case.
- A template that would call itself is refused with “Cannot Add Recursive Test Case”.
- A template used by other cases cannot be deleted until those steps are removed.
Templates, the kind chip and deleting test cases are explained in Automate.
Skip a step without deleting it#
A step can be deactivated in the step list (its menu, Deactivate). It stays in place, greyed out, and is left out of every run until you activate it again. Use it to switch off a step while you fix it, instead of deleting it.
Didn’t find your answer?Write to support with your project name and what you see on screen.
info@smartestqa.ai