① Browser-native dialogs
These call the browser's alert() / confirm() / prompt(). Playwright must register a dialog handler before clicking.
Three browser-native dialogs (alert / confirm / prompt) plus a custom
modal that supports stacking and Escape-to-close. Native dialogs are intercepted by Playwright via
page.on('dialog', ...); custom modals are just DOM you query normally.
These call the browser's alert() / confirm() / prompt(). Playwright must register a dialog handler before clicking.
A regular DOM modal — visible via data-testid="modal-confirm". Click Open another to stack a second one and confirm Playwright finds the topmost.
The textbook drill — three buttons, three native dialogs, one result line.
Alert · Confirm · Prompt. Hook a Playwright
page.on('dialog', …) handler before the click, then assert the
data-testid="alerts-result" text matches.
Each button fires its native dialog. The result line updates after you accept / dismiss / enter text.
Result: —
This is a regular DOM modal — Playwright can fill the input and click the buttons normally.
This modal sits on top. Press Escape to close just this one.