page.expect
Assert an element's state and get pass/fail plus the observed outcome; set a timeout to retry until it holds instead of failing on a race.
Instructions
Assert the state of one element and get pass/fail plus what was actually observed. Replaces the evaluate-then-eyeball-the-JSON loop. Give timeout_ms to retry until it holds instead of failing on a race.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "page.expect"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nth | No | Zero-based index when the locator matches several elements. | |
| ref | No | Snapshot ref (eNN) from page.snapshot. | |
| text | No | Visible text of the element. | |
| value | No | ||
| xpath | No | XPath expression. | |
| checked | No | ||
| enabled | No | ||
| focused | No | ||
| poll_ms | No | ||
| visible | No | ||
| frame_id | No | Frame to search within; see page.list_frames. | |
| selector | No | CSS selector; pierces shadow DOM. | |
| target_id | No | Target handle (tgt_*). Omit for the active page. | |
| browser_id | No | Browser handle (br_*). Omit to use the only running browser, or auto-launch one. | |
| timeout_ms | No | Retry until the expectations hold. Default 0: check once. | |
| in_viewport | No | ||
| text_contains | No | ||
| backend_node_id | No | CDP backendNodeId, e.g. from inspector.pick. |