Wait for a condition
wait_forBlocks until a specified page condition is met—CSS selector, text, JavaScript predicate, URL, field value, or network idle—then returns, enabling safe reads or actions on asynchronously loaded content.
Instructions
Block until a condition holds, then return. Provide exactly one of: selector (CSS present), text (appears in page text), predicate (JS expression truthy, MAIN world), networkIdle (no fetch/XHR in flight ~500ms — errors with 'network capture not active' on an http(s) page that loaded before the extension; a non-http document such as about:blank counts as idle). Follows document changes in the target tab within one timeout; network-idle timing restarts for each document. A predicate is judged SYNCHRONOUSLY: a returned promise is an object, so it counts as truthy — compare a resolved value instead. Predicates run through the debugger tier (works under a strict Content-Security-Policy; close DevTools on that tab); one that cannot parse or that the page refuses to evaluate fails immediately, while a missing global or element keeps polling and is reported with the timeout. Selector state supports attached/visible/hidden/detached; stableForMs requires truth across sampled polls and resets on false/errors/document changes. Timeouts include bounded poll/timing/document diagnostics without field values or predicate source. Use before reading/acting on content that loads asynchronously.
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>"
},
"name": "wait_for"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | Wait for exact main-frame URL | |
| text | No | Text to wait for in the page | |
| state | No | Selector state; default attached. hidden also accepts absence | |
| tabId | Yes | Target tab ID (must be in the MCP group) | |
| idleMs | No | Network-idle threshold in ms (default 500) | |
| frameId | No | Frame for selector/text/fieldValue only | |
| selector | No | CSS selector to wait for | |
| predicate | No | JS expression evaluated in the page; wait until truthy | |
| timeoutMs | No | Timeout in ms (default 15000, max 270000; Chrome terminates a worker when one request exceeds 5 minutes) | |
| fieldValue | No | Wait for a unique field value; checkbox/radio use boolean | |
| networkIdle | No | Wait until the network has been idle (default 500ms; tune with idleMs) | |
| stableForMs | No | Condition must remain true across sampled observations for this duration; resets on document changes |