Read text from an alert
Medium70 pts~25 min
- Alerts
- getText
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
Read a native alert’s message, assert it, then close the alert.
Your task
- 1Open TEST_URL and click
#alert-button. - 2Switch to the alert and read its text.
- 3Assert the text is “Hello from TargetQA”, then accept it.
- 4Assert
#alert-resultshows “Alert accepted”.
Acceptance criteria
- The alert text is read
#alert-resultshows “Alert accepted”- At least 2 assertions pass
Selenium WebDriver 4 · Selenium · Dropdowns, alerts & popups