Skip to main content

How do you handle dynamic content and iframes in Playwright or Selenium?

  • dynamic content
  • iframes
  • shadow DOM

Answer it first, then compare. Nothing here is saved or scored.

Model answer

Dynamic content: use explicit waits for the content to appear or stabilize (`waitForSelector`, `waitForLoadState`). For infinite scroll, scroll programmatically and wait for new elements. Iframes: in Playwright, use `page.frameLocator("#iframe-id")` to scope interactions. In Selenium, switch to the iframe context with `driver.switchTo().frame()`. Always switch back to the main frame when done. For shadow DOM, use Playwright's `locator()` which pierces shadow DOM by default.

What interviewers listen for

  • Test architecture instincts
    You can defend why your suite is shaped like a pyramid, a trophy, or a honeycomb.
  • Locator discipline
    You rank selector strategies by stability and explain when to break the rule.
  • Flaky test ownership
    You debug to a structural fix instead of retry-until-green.
  • Parallelisation literacy
    You know how your framework isolates state, fixtures, and database access across workers.

See all 35 automation questions

Written by , Senior QA Automation Engineer, 50+ QA candidate interviews conductedLast updated July 2026