API …
Playwright lab

Frames & shadow piercing

A payment iframe, a late-loading frame, nested frames and open/closed shadow roots.

Practice tasks

  • Fill the card form with page.frameLocator('[data-testid=fs-payment-frame]') and click Pay.
  • Assert the parent page received the postMessage (“Payment received”).
  • Wait for the lazy frame (appears after 2 s) with frameLocator and toBeVisible.
  • Reach the button two frames deep using chained frameLocator() calls.
  • Locate the nickname input inside the open shadow root with plain CSS or getByLabel (Playwright pierces open roots).
  • Explain why the closed shadow root button cannot be located, and how to test it another way.
  • List all frames with page.frames() and find one by name with page.frame({ name }).

More Playwright lab practice