Spotted something off?Report on Discord
guides
Wait For Function
Pause browser execution until a custom JavaScript expression evaluates to true, with configurable timeout.
Updated May 28, 2025
Waits until a custom JavaScript expression evaluates to
trueinside the browser, useful for dynamic content or specific page states.
Command
"wait_for_function"
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
code |
string | Yes | JavaScript code to evaluate. Must return a truthy value to proceed. |
timeout |
number | No | Max time (ms) to wait for the condition (default: 60000 ms). |
Example
Wait for element to appear
javascript1 lines
Wait for text and status change
javascript4 lines
Example Request (cURL)
bash17 lines
Notes
- The condition is evaluated in the browser context.
- It polls every 200ms until the condition is met.
- Throws an error if the timeout is reached.
- Any JavaScript expression that evaluates to true/false can be used.