Back to docs

Tool Handle Dialog

Category: Browser Automation Β· Tier: Free

Set how to handle the next JS dialog (alert, confirm, prompt). Call BEFORE the action that triggers the dialog.

Parameters

Parameter Type Required Description
action "accept" or "dismiss" Yes Accept or dismiss the dialog
promptText string No Text to enter for prompt() dialogs
_browserToken string No Browser session token

Usage Pattern

Call handle_dialog BEFORE the action that opens the dialog:

1. handle_dialog action="accept"           β†’ prepares to accept
2. click selector="#delete-button"          β†’ triggers confirm("Are you sure?")
3. (dialog auto-accepted)

For prompt dialogs:

1. handle_dialog action="accept" promptText="my-name"
2. click selector="#rename-button"          β†’ triggers prompt("Enter new name")
3. (dialog accepted with "my-name")

Related

From the Blog