Mid-LevelTest Automation & Frameworks
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 instinctsYou can defend why your suite is shaped like a pyramid, a trophy, or a honeycomb.
- Locator disciplineYou rank selector strategies by stability and explain when to break the rule.
- Flaky test ownershipYou debug to a structural fix instead of retry-until-green.
- Parallelisation literacyYou know how your framework isolates state, fixtures, and database access across workers.