Back to Practice

Iframe in Shadow DOM

Iframe inside Shadow DOM

First find the Shadow Host, traverse the Shadow DOM to find the iframe, then switch context to the iframe.

QA Automation Helper

Target IDsKey Element IDs

#shadow-host-2
#pact2
#current-destiny

Advance Testing Tips

  • Step 1: Locate Shadow Host (#shadow-host-2).
  • Step 2: Get Shadow Root.
  • Step 3: Find the iframe (#pact2) *inside* the Shadow Root.
  • Step 4: Switch to that iframe using driver.switchTo().frame(element).
  • Step 5: Click the button.