对话框
🌐 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