Selenium WebDriver 4

Handle a modal dialog and close it

Medium70 pts~25 min
  • Modals
  • Overlays
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-handle-a-modal-dialog-and-close-it

Your starter code already declares TEST_URL — never hardcode a host.

Objective

Open an in-page modal, verify it, close it, then reopen and confirm.

Your task

  1. 1Open TEST_URL and click #open-modal.
  2. 2Assert #modal-title reads “Confirm subscription”, then close with #modal-close and assert the modal is gone.
  3. 3Click #open-modal again and click #modal-confirm.
  4. 4Assert #modal-result shows “Subscription confirmed”.

Acceptance criteria

  • #modal is closed at the end
  • #modal-result shows “Subscription confirmed”
  • At least 3 assertions pass

Selenium WebDriver 4 · Selenium · Dropdowns, alerts & popups