Selenium WebDriver 4

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.

Test URL
/lab/selenium-read-text-from-an-alert

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

  1. 1Open TEST_URL and click #alert-button.
  2. 2Switch to the alert and read its text.
  3. 3Assert the text is “Hello from TargetQA”, then accept it.
  4. 4Assert #alert-result shows “Alert accepted”.

Acceptance criteria

  • The alert text is read
  • #alert-result shows “Alert accepted”
  • At least 2 assertions pass

Selenium WebDriver 4 · Selenium · Dropdowns, alerts & popups