Explain the difference between implicit waits, explicit waits, and hard sleeps. Which should you use?
- waits
- synchronization
- best practices
Answer it first, then compare. Nothing here is saved or scored.
Model answer
Hard sleeps (`sleep(5000)`) waste time and are still flaky, avoid them. Implicit waits set a global timeout for element lookups but hide real problems. Explicit waits (`waitForSelector`, `waitForResponse`) wait for specific conditions and are the gold standard, they're precise and self-documenting. Playwright's auto-wait handles most cases, so you rarely need manual waits. When you do, always wait for a specific condition (element visible, network idle) rather than a fixed time.
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.