wait* timed out or page loads async content. Wait for signal work is done, not arbitrary delay.
| Situation | Use |
|---|---|
| Know API endpoint | waitForResponse { url, statuses: [200] } |
| Know CSS selector appears | waitForSelector { selector, timeout } |
| Page navigates | waitForNavigation { timeout } |
| Nothing specific (last resort) | waitForTimeout { time: 3000 } |
waitForResponse most reliable — fires on network event. Prefer when URL pattern known.
Search results:
{
"commands": [
{ "method": "type", "params": { "selector": "input#q", "text": "query" } },
{ "method": "click", "params": { "selector": "button#search" } },
{
"method": "waitForResponse",
"params": { "url": "*api/search*", "statuses": [200] }
},
{ "method": "snapshot" }
]
}Form with redirect:
{
"commands": [
{ "method": "click", "params": { "selector": "button#submit" } },
{ "method": "waitForNavigation", "params": { "timeout": 10000 } },
{ "method": "snapshot" }
]
}Lazy modal:
{
"commands": [
{ "method": "click", "params": { "selector": "button#open" } },
{
"method": "waitForSelector",
"params": { "selector": "[role='dialog']", "timeout": 5000 }
},
{ "method": "snapshot" }
]
}- Re-snapshot — content may already be there (wrong wait condition)
- Widen pattern —
*api/search*matches more than exact URL - Switch wait type — if
waitForResponsefails, trywaitForSelectorfor rendered output - Last resort:
waitForTimeout { time: 3000 }
evaluatewith setTimeout/Promise (returns before timer completes)
- Multiple
waitForTimeoutstacked (use specific wait methods) - Tight snapshot loop without wait (burns tokens, races page)