Selenium WebDriver 4

Switch back to the default content

Medium70 pts~25 min
  • iframes
  • Default content
Practice app · Secure Checkout

A payment widget inside an iframe and a nested iframe structure.

Test URL
/lab/selenium-switch-back-to-the-default-content

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

Objective

Complete the payment inside the iframe, then return to the top-level document and fill in the delivery note.

Your task

  1. 1Switch into #payment-frame and pay with card 4242424242424242 (#card-number, #pay-button).
  2. 2Assert #pay-result reads “Payment authorized”.
  3. 3Switch back with defaultContent() / default_content() / DefaultContent().
  4. 4Assert #main-heading reads “Secure checkout” and type “Leave at reception” into #order-note.

Acceptance criteria

  • defaultContent is used to leave the frame
  • #pay-result shows “Payment authorized”
  • #order-note contains “Leave at reception”
  • At least 2 assertions pass

Selenium WebDriver 4 · Selenium · Frames, windows & tabs