Handle an alert or confirm dialog
Medium70 pts
- Dialogs
- Alerts
- Event Handlers
Practice app · UI Widgets Lab
Native alerts, confirm and prompt dialogs, a modal, a cookie banner, custom dropdown, autocomplete, date picker and tooltip.
Your starter code already declares TEST_URL — never hardcode a host.
Objective
Accept a JavaScript alert dialog and verify the resulting confirmation message.
Your Task
- 1Navigate to the interactive widgets page at TEST_URL.
- 2Register a one-time dialog listener to accept the upcoming dialog.
- 3Click the alert trigger button (#alert-button) to open the native alert.
- 4Assert that the alert result element (#alert-result or #dialog-result) is visible and displays 'Alert accepted'.
Validation Checks
- Interactive widgets page is loaded at TEST_URL
- Dialog listener is registered on page
- Alert button (#alert-button) is clicked
- Alert result element (#alert-result) is visible and displays 'Alert accepted'
- At least 1 assertion passes
Playwright · Playwright Practice Track · Actions & inputs