Skip to content

Dialogs

Updated View as Markdown

Use the session’s CDP connection to observe Page.javascriptDialogOpening and respond with Page.handleJavaScriptDialog. Register the handler before navigating or clicking the action that opens a dialog.

// client is an already connected, page-scoped CDP session.
await client.send("Page.enable");
client.on("Page.javascriptDialogOpening", async () => {
  await client.send("Page.handleJavaScriptDialog", {accept: false});
});

Choose acceptance or prompt text according to the intended user action. Browser permission prompts, website sign-in and human checks are different from JavaScript alert, confirm and prompt dialogs.

See Create a browser session and the Browsers API for authentication, request fields, and limits.

Type to search…

↑↓ navigate↵ selectEsc close