Manuals / Playwright with Python / Chapter 17
Part 2 · Core Interactions · intermediate · ~35 min · Chapter 17 of 61
11. Alerts, Dialogs, Popups
page.on("dialog", lambda dialog: dialog.accept()) page.get_by_role("button", name="Delete account").click() # triggers confirm() Native browser dialogs (alert(), confirm(), prompt()) block all further JavaScript execution until dismissed. You must register a handler before triggering the action that opens the dialog — if you forget, the dialog blocks the page indefinitely and your test times out w
Step 1 of 4
Overview
Native browser dialogs (alert(), confirm(), prompt()) block all further JavaScript execution until dismissed. You must register a handler before triggering the action that opens the dialog — if you forget, the dialog blocks the page indefinitely and your test times out waiting.
Try it
Run / study this snippet
page.on("dialog", lambda dialog: dialog.accept())Chapter learning outcomes
- page.on("dialog", lambda dialog: dialog.accept()) page.get_by_role("button", nam
- You must register a handler before triggering the action that opens the dialog —
Clear these before you leave
Side quest
11. Alerts, Dialogs, Popups deliverable
Apply one idea from “Overview” in a small script or note.