Wait For
Wait For
Section titled “Wait For”Type: page-wait-for · Package: Browser v1.0.9
Pauses the flow until an element reaches the state you specify. It’s the essential tool for making your web automations reliable: instead of guessing with a fixed Delay how long a page takes, you wait exactly until the element you need is ready.
How it works
Section titled “How it works”It watches the element given by the selector and waits until it reaches the requested state (or until timeout runs out, in which case it fails). As soon as it’s met, the flow continues immediately — neither earlier nor later. If the state is already met when it starts, it continues instantly.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | selector | — | The element to wait for. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
page | ZoanPageSession | — | The page session. Omit it inside a body; outside, pass the session variable (e.g. page = page). |
state | string | "visible" | State to wait for: visible · hidden · attached · detached (see table). Case-insensitive: Hidden is the same as hidden (since version 1.0.8; before, any value not written exactly in lowercase was treated as visible). |
timeout | number | 30000 | Maximum time in ms to wait. Empty, 0 or negative: the project settings value or, if none, 30000. |
States
Section titled “States”| State | In the Designer | Waits for the element to… |
|---|---|---|
visible | Visible | Exist and be visible: with a size and without visibility: hidden (the most used). |
hidden | Hidden | Not be visible or not exist (e.g. a loading spinner that disappears). |
attached | On the page | Exist in the HTML, even if not visible. |
detached | Off the page | Stop existing in the HTML. |
With visible and attached, the selector must point to a single element; if it matches several, the activity fails and says how many it found.
Output
Section titled “Output”This activity does not return a value. If you need a true/false instead of a failure, use Element Exists.
Example
Section titled “Example”Wait for the dashboard to load after signing in, and for the spinner to disappear:
Page Click selector = (#entrar)Page Wait For selector = (.spinner-carga) state = hidden // wait for loading to finishPage Wait For selector = (.dashboard) state = visible // and for the content to appearCommon errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
Wait failed: Timeout 30000ms exceeded. … | matches: 0 (element not found: …) | The element didn’t reach the state in time. Check the selector, raise timeout or use Element Exists if the element may not appear. |
Wait failed: … | matches: 2 (the selector is ambiguous: …) | The selector matches several elements. Make it more specific or add an index. |
No elements match the selector, so the anchors cannot be applied. | The selector uses anchors and the element doesn’t exist yet: with anchors there is no waiting. Wait for an element without anchors on the same screen. |
'state' must be visible, hidden, attached or detached (got '…'). / [page-wait-for] Invalid value '…' for 'state'. Allowed: visible, hidden, attached, detached. | state isn’t one of the four allowed values. Choose one from the list. |
'page' must be a ZoanPageSession. | page is empty outside a body. |
Related activities
Section titled “Related activities”- Element Exists — check presence without failing (returns true/false).
- Navigate — its
waitUntilparameter controls the page-load wait. - Delay — a fixed wait (less reliable; use it as a last resort).