Skip to content

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.

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.

ParameterTypeDefaultDescription
selectorselector—The element to wait for.
ParameterTypeDefaultDescription
pageZoanPageSession—The page session. Omit it inside a body; outside, pass the session variable (e.g. page = page).
statestring"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).
timeoutnumber30000Maximum time in ms to wait. Empty, 0 or negative: the project settings value or, if none, 30000.
StateIn the DesignerWaits for the element to…
visibleVisibleExist and be visible: with a size and without visibility: hidden (the most used).
hiddenHiddenNot be visible or not exist (e.g. a loading spinner that disappears).
attachedOn the pageExist in the HTML, even if not visible.
detachedOff the pageStop 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.

This activity does not return a value. If you need a true/false instead of a failure, use Element Exists.

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 finish
Page Wait For selector = (.dashboard) state = visible // and for the content to appear
MessageCause 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.
  • Element Exists — check presence without failing (returns true/false).
  • Navigate — its waitUntil parameter controls the page-load wait.
  • Delay — a fixed wait (less reliable; use it as a last resort).