You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We want to have the functionality to interact with the dialog box in the same way as Playwright's page.on method.
Suggested Solution (optional)
We need to implement the CDP listener handleJavaScriptDialog. If a page.on("dialog") listener has not been called prior to navigating to a page with an alert window, the dialog should automatically be dismissed.
This listener needs to be set prior to the navigation. There are two methods that can be called on the dialog object, one is accept(promptText) and the other is dismiss. promptText is only really needed when the dialog box is of type prompt, if it is added then it doesn't change the behaviour in any way.
Listener must either accept([promptText]) or dialog.dismiss() the dialog - otherwise the page will freeze waiting for the dialog, and actions like click will never finish.
Playwright script:
const{ test, chromium }=require('@playwright/test');test.describe('lifecycle',()=>{test('lifecycle',async()=>{constbrowser=awaitchromium.launch({headless: false});constctx=awaitbrowser.newContext();constpage=awaitctx.newPage();// This listener will be called when we navigate to the page.page.on("dialog",(dialog)=>{dialog.accept();console.log("accept 1");})awaitpage.goto("http://localhost:8080/dialogbox",{waitUntil: 'networkidle'});// Listener set, but nothing will call it.page.on("dialog",(dialog)=>{dialog.accept();console.log("accept 2");})// Another listener set, but nothing will call it.page.on("dialog",(dialog)=>{dialog.accept();console.log("accept 3");})awaitbrowser.close();});});
Already existing or connected issues / PRs (optional)
No response
The text was updated successfully, but these errors were encountered:
Feature Description
Given a website which pop ups a dialog box (
alert
,prompt
,confirm
orbeforeunload
) such as:We want to have the functionality to interact with the dialog box in the same way as Playwright's page.on method.
Suggested Solution (optional)
We need to implement the CDP listener handleJavaScriptDialog. If a
page.on("dialog")
listener has not been called prior to navigating to a page with an alert window, the dialog should automatically be dismissed.This listener needs to be set prior to the navigation. There are two methods that can be called on the dialog object, one is
accept(promptText)
and the other isdismiss
.promptText
is only really needed when the dialog box is of typeprompt
, if it is added then it doesn't change the behaviour in any way.Listener must either
accept([promptText])
ordialog.dismiss()
the dialog - otherwise the page will freeze waiting for the dialog, and actions like click will never finish.Playwright script:
Already existing or connected issues / PRs (optional)
No response
The text was updated successfully, but these errors were encountered: