Wait for a mini program condition
mp_waitWaits with a hard deadline until an element appears or disappears, text contains a string, the page reaches a path, or page data equals a value. On timeout it reports the last observation, replacing fixed sleeps before assertions.
Instructions
Wait until an element appears or disappears, an element text contains a string, the page reaches a path, or a page data path equals a value — with a hard deadline. On timeout it reports what was observed last, so you can tell a slow render from a wrong expectation. Use this instead of sleeping a fixed time before an assertion.
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": {
"condition": "<condition>"
},
"name": "mp_wait"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Page route for page_path, or the data path for page_data (e.g. "form.submitted"). | |
| text | No | Substring the element text must contain, for text_contains. | |
| xpath | No | Treat selector as XPath. | |
| poll_ms | No | Interval between checks. Defaults to 250. | |
| expected | No | Value the data path must equal, for page_data. Compares with strict JSON equality. | |
| selector | No | Element selector, required by selector_present/selector_absent/text_contains. | |
| condition | Yes | What to wait for: selector_present, selector_absent, text_contains, page_path, page_data. | |
| timeout_ms | No | Deadline for the condition. Defaults to 15000. | |
| container_selector | No | Resolve this first and search inside it. |