wait_for
Pause automation until a selector appears, a JavaScript function returns true, or a URL matches a pattern. Avoid fixed timeouts; use conditional waits for efficient browser control.
Instructions
Wait for a condition. Strongly prefer 'function', 'selector', or 'url_match' — they return as soon as the condition is true (1 round-trip). Use 'timeout' only as a last resort: it blocks for a fixed duration and returns no information, forcing you to poll with another tool afterwards.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"tabId": "<tabId>",
"type": "<type>"
},
"name": "wait_for"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | Condition. PREFER: 'selector' (element appears), 'selector_hidden', 'function' (custom JS predicate, e.g. value="document.querySelectorAll('.error').length>0"), 'url_match', 'navigation'. AVOID 'timeout' — it just sleeps. | |
| tabId | Yes | Tab ID to wait on | |
| value | No | Selector, JS function, URL pattern, or ms | |
| timeout | No | Max wait in ms. Default: 30000 | |
| visible | No | Require visibility (selector). Default: false | |
| pollIntervalMs | No | Function mode only: predicate polling interval in ms for main-frame evaluation. Default 200, min 50, max 5000. |