Dialog & Download Actions
Actions for handling browser dialogs (alert, confirm, prompt), waiting for downloads and network activity, and clicking on canvas elements.
init_dialog
Register a default dialog handler before the action that triggers it. Browser dialogs (alert, confirm, prompt) block the page — if you don't have a listener ready, the script hangs. This sets up an auto-accept handler for the next dialog.
| Param | Type | Description |
|---|---|---|
| No parameters — registers a default accept handler. | ||
// Set up handler BEFORE the click that triggers the dialog
[
{ "type": "init_dialog" },
{ "type": "click", "selector": "#delete-btn" }
]handle_dialog
Configure how browser dialogs are handled. Sets the action (accept or dismiss), optional prompt text, and whether the handler persists for all future dialogs.
| Param | Type | Description |
|---|---|---|
| actionoptional | string | "accept" (default) or "dismiss". Alias: dialogAction. |
| textoptional | string | Text to enter in prompt() dialogs before accepting. Alias: promptText. |
| persistentoptional | boolean | If true, handle ALL future dialogs this way (not just the next one). Default: false. |
// Dismiss a dialog
{ "type": "handle_dialog", "action": "dismiss" }
70
{ "type": "handle_dialog", "action": "accept", "text": "CONFIRM" }
165
{ "type": "handle_dialog", "action": "accept", "persistent": true }init_dialog vs handle_dialog
| Scenario | Use |
|---|---|
| You know which click opens the dialog | init_dialog → click |
| Dialog appears on page load | handle_dialog (reactive) |
| Need to dismiss instead of accept | handle_dialog with action: "dismiss" |
| All dialogs on this page should be accepted | handle_dialog with persistent: true |
wait_for_download
Wait for a file download to complete. Optionally clicks a trigger element first. Resolves when the file has been fully saved. Reports the filename when done.
| Param | Type | Description |
|---|---|---|
| selectoroptional | string | Click this element to trigger the download. Alias: triggerSelector. |
| timeoutoptional | number | Max wait time in ms. Default: 30000. |
// Click the download button and wait for the file
{ "type": "wait_for_download", "selector": "#download-report", "timeout": 60000 }
134
{ "type": "wait_for_download" }wait_for_network_idle
Waits for all network requests to settle. Useful after navigation or AJAX-heavy operations to ensure the page has finished loading data.
| Param | Type | Description |
|---|---|---|
| timeoutoptional | number | Max time to wait in ms. Default: 10000. |
| idleTimeoptional | number | How long the network must be quiet to be considered idle, in ms. Default: 500. Alias: idle_time. |
{ "type": "wait_for_network_idle" }
{ "type": "wait_for_network_idle", "timeout": 15000, "idleTime": 1000 }
110
{ "type": "network_idle", "timeout": 5000 }click_canvas
Click at specific pixel coordinates within a canvas element. Used for map interactions, drawing tools, or any canvas-based UI.
| Param | Type | Description |
|---|---|---|
| selectorrequired | string | array | CSS selector for the canvas element. |
| xrequired | number | X coordinate within the canvas (pixels from left edge). Default: 0. |
| yrequired | number | Y coordinate within the canvas (pixels from top edge). Default: 0. |
| indexoptional | number | Which visible canvas to click (0 = first). Default: 0. |
{ "type": "click_canvas", "selector": "canvas#map", "x": 150, "y": 200 }
{ "type": "click_canvas", "selector": ".drawing-canvas", "x": 50, "y": 50 }