Skip to main content

对话框

🌐 Dialogs

处理阻止页面交互的浏览器对话框(警告、确认、提示)。

🌐 Handle browser dialogs (alert, confirm, prompt) that block page interaction.

browser_handle_dialog

参数类型是否必填描述
accept布尔值true 接受,false 拒绝
promptText字符串用于提示对话框中输入的文本

当出现对话框时,其他工具会在它们的响应中报告。在继续之前处理该对话框。

🌐 When a dialog appears, other tools will report it in their response. Handle the dialog before continuing.

警告对话框

🌐 Alert dialog

→ browser_click { ref: "e5" }
⚠ Dialog appeared: [alert] "Are you sure you want to delete this?"

→ browser_handle_dialog { accept: true }

确认对话框

🌐 Confirm dialog

→ browser_click { ref: "e10" }
⚠ Dialog appeared: [confirm] "Are you sure you want to delete this?"

→ browser_handle_dialog { accept: true } // click OK
→ browser_handle_dialog { accept: false } // click Cancel

提示对话框

🌐 Prompt dialog

→ browser_click { ref: "e8" }
⚠ Dialog appeared: [prompt] "Enter your name:"

→ browser_handle_dialog { accept: true, promptText: "My new name" }

工作流程

🌐 Workflow

当出现对话框时,其他工具会在它们的响应中报告。在继续之前处理该对话框:

🌐 When a dialog appears, other tools will report it in their response. Handle the dialog before continuing:

→ browser_click { ref: "e12" }
⚠ Dialog appeared: [confirm] "Discard unsaved changes?"

→ browser_handle_dialog { accept: true }

→ browser_snapshot
// Page now shows updated state after dialog was accepted