Selenium WebDriver 4

Handle nested iframes

Hard120 pts~45 min
  • Nested iframes
  • parentFrame
  • Default content
Practice app · Secure Checkout

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

Test URL
/lab/selenium-handle-nested-iframes

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

Objective

Reach an iframe nested inside another iframe, read its content and carry it back to the top-level page.

Your task

  1. 1Switch into #outer-frame, then into #inner-frame (it only exists inside the outer frame).
  2. 2Read the bold first line of the inner frame and assert it is “Inside nested frame”.
  3. 3Return to the top document (defaultContent, or parentFrame twice).
  4. 4Type the text you read into #order-note.

Acceptance criteria

  • Two frame switches are chained
  • The driver returns to the top document
  • #order-note contains “Inside nested frame”
  • At least 1 assertion passes

Selenium WebDriver 4 · Selenium · Frames, windows & tabs