Block reference / Web interaction
Wait for
Wait until an element appears or goes, the address matches, or a network response arrives.
Only in
WarpX Browser
Wait for holds the run until something happens on the page instead of waiting a fixed time: an element shows up or disappears, the address changes to one you expect, or the site answers a request. If it does not happen in time, the block leaves by its fallback output, so you can handle a page that never got there.
Settings
- Description
A note shown on the block in the canvas.
ExampleLogin answer- Wait until
What to wait for: An element appears, An element goes away, The address matches or A network response arrives.
ExampleA network response arrives- CSS selector / XPathwhen Wait until is An element appears or An element goes away
The two choices above Element: how the selector is written.
ExampleCSS selector- Elementwhen Wait until is An element appears or An element goes away
The CSS selector or XPath of the element. It counts as there when it takes up room on the page and is not hidden,
display: noneor fully transparent.Example.feed-loaded- Address containswhen Wait until is The address matches
Part of the address to wait for. Plain text matches anywhere in the address, ignoring case;
*is a wildcard, as in*/checkout/*/done; and text written between slashes, such as/\/order\/\d+/, is a regular expression.Example/home- Request address containswhen Wait until is A network response arrives
Part of the address of the request whose response you want, matched the same way as an address. Empty accepts any response.
Example/api/login- Methodwhen Wait until is A network response arrives
Only accept a request of this method: Any, GET, POST, PUT, PATCH or DELETE.
ExamplePOST- Also accept one from the last (seconds)when Wait until is A network response arrives
A matching response that arrived this many seconds before the block started also counts. That way a click in the block just before cannot have already missed the answer.
0waits only for a new one.Example10- Give up after (ms)
How long to wait before leaving by the fallback output. Anything under
1000counts as one second.Example30000- Assign to variablewhen Wait until is The address matches or A network response arrives
Store what was waited for in a variable: the address, or the response.
ExampleChecked- Variable namewhen Assign to variable is ticked
The variable that receives it.
ExampleloginResponse
Every block also has the shared block settings — a description, Disable block and what to do on an error, and Finding elements explains selectors in more depth. Fields that take text accept data from earlier blocks.
What it hands on
When it happens, the block leaves by its top output. For an address, the variable and {{prevBlockData}} get the full address. For a response they get { url, status, body }, the body parsed when it is JSON, so {{variables.loginResponse.status}} and {{variables.loginResponse.body.token}} work. When time runs out it leaves by the fallback output; with nothing connected there, the block fails with a message such as No response matching "/api/login" within 30s.
Example: Read the JSON answer of a login
- Start
- Open URL
- Forms
- Forms
- Click element
- Wait for
- Conditions
- Add an Open URL block with
https://app.example.com/login. - Add two Forms blocks that fill
#emailwith{{variables.email}}and#passwordwith{{variables.password}}. - Add a Click element block on
button[type=submit]. - Add a Wait for block: Wait until A network response arrives, Request address contains
/api/login, Method POST, Also accept one from the last (seconds)10, Give up after (ms)30000. - Tick Assign to variable and name it
loginResponse. - Add a Conditions block with a path
{{variables.loginResponse.status}}Equals200, and read the user's id from{{variables.loginResponse.body.user.id}}after it. - Connect the Wait for block's fallback output to whatever should happen when the site never answered, such as a Retry block.
Good to know
- An element is checked about every 0.3 seconds and the address about every 0.4 seconds. A page that is between two documents is simply asked again.
- Waiting for an element or the address stores nothing in a variable; Assign to variable is only offered for the address and network modes.
- Network mode needs the WarpX Browser desktop app, where it works on every engine. Each page remembers its last 200 responses, newest first, and a body larger than 2 MB is cut.
- A selector that is not valid fails the block at once rather than waiting for the time to run out.
- Text that starts and ends with
/, optionally followed by flags such asi, is read as a regular expression./api/loginis not:loginis not a set of flags, so it matches as plain text.
See also
- Element exists — Check whether an element is on the page and continue by one of two outputs.
- Retry — Send the run back to try a part of the workflow again, a set number of times, then give up by its fallback.
- Delay — Pauses the run for a set number of milliseconds before the next block.