---
title: "Waits, conditions and templates"
section: "Step reference"
description: "Control the flow of a SmartestQA test case: Wait (seconds), Wait For steps, timeouts and retries, IF/ELSE conditions in Python steps, and reusable template steps."
url: https://docs.smartestqa.ai/en/automate-steps-flow.html
audience: [customer, admin]
updated: 2026-11-08
keywords: "wait seconds wait for element wait timeout page load timeout retry if elif else end condition branch loop template reuse sub test case flow control"
---
# Step reference: 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**

1. Save the value your condition needs with a Get, API or Database step.
2. Add a Python step, set Select an option to IF and write the condition.
3. Add the steps of the branch, then a Python step set to ELSE or END .
4. For reuse, mark a test case as a template, then add it with Template .
5. Run a Dry Run and read the [IF] Condition evaluated line.

## Waits

Most steps already wait: an element step [waits for its element](https://docs.smartestqa.ai/en/automate-steps-browser.html#finding-elements), a [Visibility Check](https://docs.smartestqa.ai/en/automate-steps-browser.html#visibility-check) retries for up to 8 seconds, mail and [Kafka steps](https://docs.smartestqa.ai/en/automate-steps-kafka.html#consume) 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)**](https://docs.smartestqa.ai/en/automate-steps-browser.html#wait-seconds) | All | The time has passed | 0.1–3600 seconds, decimals allowed, or a [variable](https://docs.smartestqa.ai/en/automate-steps-variables.html#syntax) |
| [Wait For Element](https://docs.smartestqa.ai/en/automate-steps-mobile.html#assert-wait) | 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)](https://docs.smartestqa.ai/en/automate-steps-desktop.html#scroll-wait) | DESKTOP | The time has passed | Seconds |
| [Wait for Mail](https://docs.smartestqa.ai/en/automate-steps-mail.html#wait-for-mail) | All | A matching email arrives | Filters and timeout |
| [Network Check](https://docs.smartestqa.ai/en/automate-steps-network.html#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”.

> **Tip: 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](https://docs.smartestqa.ai/en/project-settings-test-management.html#timeouts):

- **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](https://docs.smartestqa.ai/en/maintenance-how-healing-works.html#when) start.

**Time before a missing element fails** — Any web element step

```text
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](https://docs.smartestqa.ai/en/automate-steps-browser.html#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](https://docs.smartestqa.ai/en/automate-steps-ai.html#run-time) gets 35 seconds more.
- A pipeline can retry failed test cases ([Retry Count in Schedule](https://docs.smartestqa.ai/en/schedule-settings.html#test-management)). A [**Dry Run**](https://docs.smartestqa.ai/en/automate-dry-run.html#start-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.

1. **Save the value to test**

   For example, a [Get step](https://docs.smartestqa.ai/en/automate-steps-browser.html#get) saves the number of orders into `orderCount`.
2. **Add the IF step**

   Click [**Python**](https://docs.smartestqa.ai/en/automate-steps-code.html#add-code-step). In the right panel set **Select an option** to **IF** and write the condition as a Python expression: `int({{tc:orderCount}}) > 0`.
3. **Add the branch**

   Add the steps that should run when the condition is true, for example Click `Details`.
4. **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.

Example · branch on the order count

```text
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](https://docs.smartestqa.ai/en/automate-steps-variables.html#syntax) is replaced by its text. Wrap it: `int(…)`, or `float(…)` for decimals. Without it, `"5" > 10` raises 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 evaluated` with the condition, the resolved values and `TRUE → branch body executed` or `FALSE → moved to ELSE branch`.
- If the condition raises an error, the line is `[IF] Condition could not be evaluated` with 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](https://docs.smartestqa.ai/en/automate-steps-troubleshooting.html#fix-flow-invalid).

An IF, ELIF, ELSE or END step has no output variable; only a plain Python step does. More on Python code in [Code steps](https://docs.smartestqa.ai/en/automate-steps-code.html).

## 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.

1. **Make a template**

   Open the test case to reuse. Click the [kind chip](https://docs.smartestqa.ai/en/automate-test-cases.html#case-kind) in its header, choose **Template** and save.
2. **Add it to another case**

   In the other test case click **Template**. The dialog [**Template Test Cases**](https://docs.smartestqa.ai/en/automate-add-steps.html#add-template) lists the [project’s templates](https://docs.smartestqa.ai/en/automate-add-steps.html#add-template). The current case and templates that already call it are left out, so you cannot build a loop. Click a template to add it.
3. **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.](https://docs.smartestqa.ai/en/automate-test-data.html#variable-scope)** 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”](https://docs.smartestqa.ai/en/automate-troubleshooting.html#fix-recursive).
- A template used by other cases [cannot be deleted](https://docs.smartestqa.ai/en/automate-troubleshooting.html#fix-archive-template) until those steps are removed.

Templates, the kind chip and deleting test cases are explained in [Automate](https://docs.smartestqa.ai/en/automate.html).

## Skip a step without deleting it

A step can be [deactivated in the step list](https://docs.smartestqa.ai/en/automate-editor.html#activate-deactivate) (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.
