Accept a JavaScript alert
Medium70 pts~25 min
- Alerts
- switchTo
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
Trigger a native alert, switch to it and accept it.
Your task
- 1Open TEST_URL and click
#alert-button. - 2Wait for the alert, switch to it and accept it.
- 3Assert
#alert-resultshows “Alert accepted”.
Acceptance criteria
- The test switches to the alert
- The alert is accepted
#alert-resultshows “Alert accepted”- At least 1 assertion passes
Selenium WebDriver 4 · Selenium · Dropdowns, alerts & popups