1"use strict";(self.webpackChunkplaywright_dev=self.webpackChunkplaywright_dev||[]).push([["3585"],{46083(e,l,a){a.r(l),a.d(l,{metadata:()=>r,default:()=>h,frontMatter:()=>n,contentTitle:()=>o,toc:()=>s,assets:()=>i});var r=JSON.parse('{"id":"tools/dialogs","title":"Dialogs","description":"Handle browser dialogs (alert, confirm, prompt, beforeunload) that block page interaction.","source":"@site/mcp/tools/dialogs.mdx","sourceDirName":"tools","slug":"/tools/dialogs","permalink":"/mcp/tools/dialogs","draft":false,"unlisted":false,"tags":[],"version":"current","frontMatter":{"title":"Dialogs"},"sidebar":"mcp","previous":{"title":"Tabs","permalink":"/mcp/tools/tabs"},"next":{"title":"File Upload","permalink":"/mcp/tools/file-upload"}}'),d=a(74848),t=a(28453);let n={title:"Dialogs"},o="Dialogs",i={},s=[{value:"browser_handle_dialog",id:"browser_handle_dialog",level:2},{value:"Alert dialog",id:"alert-dialog",level:3},{value:"Confirm dialog",id:"confirm-dialog",level:3},{value:"Prompt dialog",id:"prompt-dialog",level:3},{value:"Workflow",id:"workflow",level:2}];function c(e){let l={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,t.R)(),...e.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l.header,{children:(0,d.jsx)(l.h1,{id:"dialogs",children:"Dialogs"})}),"\n",(0,d.jsx)(l.p,{children:"Handle browser dialogs (alert, confirm, prompt, beforeunload) that block page interaction."}),"\n",(0,d.jsx)(l.h2,{id:"browser_handle_dialog",children:"browser_handle_dialog"}),"\n",(0,d.jsxs)(l.table,{children:[(0,d.jsx)(l.thead,{children:(0,d.jsxs)(l.tr,{children:[(0,d.jsx)(l.th,{children:"Parameter"}),(0,d.jsx)(l.th,{children:"Type"}),(0,d.jsx)(l.th,{children:"Required"}),(0,d.jsx)(l.th,{children:"Description"})]})}),(0,d.jsxs)(l.tbody,{children:[(0,d.jsxs)(l.tr,{children:[(0,d.jsx)(l.td,{children:(0,d.jsx)(l.code,{children:"accept"})}),(0,d.jsx)(l.td,{children:"boolean"}),(0,d.jsx)(l.td,{children:"yes"}),(0,d.jsxs)(l.td,{children:[(0,d.jsx)(l.code,{children:"true"})," to accept, ",(0,d.jsx)(l.code,{children:"false"})," to dismiss"]})]}),(0,d.jsxs)(l.tr,{children:[(0,d.jsx)(l.td,{children:(0,d.jsx)(l.code,{children:"promptText"})}),(0,d.jsx)(l.td,{children:"string"}),(0,d.jsx)(l.td,{children:"no"}),(0,d.jsx)(l.td,{children:"The text of the prompt in case of a prompt dialog"})]})]})]}),"\n",(0,d.jsx)(l.p,{children:"While a dialog is open, every other tool refuses to run and reports the modal state instead:"}),"\n",(0,d.jsx)(l.pre,{children:(0,d.jsx)(l.code,{className:"language-txt",children:'### Modal state\n- ["alert" dialog with message "Alert"]: can be handled by browser_handle_dialog\n'})}),"\n",(0,d.jsx)(l.p,{children:"Handle the dialog before continuing."}),"\n",(0,d.jsx)(l.h3,{id:"alert-dialog",children:"Alert dialog"}),"\n",(0,d.jsx)(l.pre,{children:(0,d.jsx)(l.code,{className:"language-txt",children:'\u2192 browser_click { target: "e5" }\n\n ### Modal state\n - ["alert" dialog with message "Item deleted"]: can be handled by browser_handle_dialog\n\n\u2192 browser_handle_dialog { accept: true }\n'})}),"\n",(0,d.jsx)(l.h3,{id:"confirm-dialog",children:"Confirm dialog"}),"\n",(0,d.jsx)(l.pre,{children:(0,d.jsx)(l.code,{className:"language-txt",children:'\u2192 browser_click { target: "e10" }\n\n ### Modal state\n - ["confirm" dialog with message "Are you sure you want to delete this?"]: can be handled by browser_handle_dialog\n\n\u2192 browser_handle_dialog { accept: true } // click OK\n\u2192 browser_handle_dialog { accept: false } // click Cancel\n'})}),"\n",(0,d.jsx)(l.h3,{id:"prompt-dialog",children:"Prompt dialog"}),"\n",(0,d.jsx)(l.pre,{children:(0,d.jsx)(l.code,{className:"language-txt",children:'\u2192 browser_click { target: "e8" }\n\n ### Modal state\n - ["prompt" dialog with message "Enter your name:"]: can be handled by browser_handle_dialog\n\n\u2192 browser_handle_dialog { accept: true, promptText: "My new name" }\n'})}),"\n",(0,d.jsx)(l.h2,{id:"workflow",children:"Workflow"}),"\n",(0,d.jsx)(l.pre,{children:(0,d.jsx)(l.code,{className:"language-txt",children:'\u2192 browser_click { target: "e12" }\n\n ### Modal state\n - ["confirm" dialog with message "Discard unsaved changes?"]: can be handled by browser_handle_dialog\n\n\u2192 browser_handle_dialog { accept: true }\n\n\u2192 browser_snapshot\n // Page now shows updated state after the dialog was accepted\n'})}),"\n",(0,d.jsx)(l.admonition,{type:"note",children:(0,d.jsxs)(l.p,{children:["File choosers are reported the same way, and are cleared with ",(0,d.jsx)(l.code,{children:"browser_file_upload"})," rather than\n",(0,d.jsx)(l.code,{children:"browser_handle_dialog"}),". See ",(0,d.jsx)(l.a,{href:"/mcp/tools/file-upload",children:"File Upload"}),"."]})})]})}function h(e={}){let{wrapper:l}={...(0,t.R)(),...e.components};return l?(0,d.jsx)(l,{...e,children:(0,d.jsx)(c,{...e})}):c(e)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.