The Dundies · JavaScript Alerts

Native browser dialogs: alert(), confirm() and prompt() — practice handling each one and asserting how it was handled.

alert(), confirm(), prompt() — the annual awards nobody can dismiss politely.

JavaScript Alerts is an easy Forms & Inputs challenge on Fun UI Playground. Native browser dialogs: alert(), confirm() and prompt() — practice handling each one and asserting how it was handled. It runs entirely in the browser, with no backend. Every interactive element carries a stable id and data-testid prefixed with “alerts-”, and the techniques it exercises are handle alert(), accept/dismiss confirm(), type into prompt(), assert dialog result.

At a glance

Category
Forms & Inputs
Difficulty
easy
Teaches
handle alert() · accept/dismiss confirm() · type into prompt() · assert dialog result
Backend
None — runs entirely in the browser
Locators
Stable id and data-testid, prefixed alerts-

Selectors on this page

LocatorWhat it is
#alerts-alert #alerts-confirm #alerts-promptButtons: #alerts-alert, #alerts-confirm, #alerts-prompt
#alerts-resultEach interaction writes its outcome to #alerts-result — e.g. "You accepted the Dundie" or "Speech: <your text>"

Frequently asked questions

How do I handle alert(), confirm() and prompt() in an automated test?

Register the dialog handler before clicking, because native dialogs block the page. Then click #alerts-alert, #alerts-confirm or #alerts-prompt and assert the outcome text in #alerts-result — for example "You accepted the Dundie".

Why does my test hang on a JavaScript alert?

Almost always because the handler was registered after the click. The dialog blocks the page, so the driver never reaches the line that would dismiss it. Attach the listener first, then trigger the dialog.

More Forms & Inputs

Updated

Fun UI Playground — all challenges, bug hunts, getting started, glossary, about.