Compare Selenium and Playwright. When would you choose each?
What the interviewer wants to hear
- Selenium: W3C WebDriver standard, many languages, huge ecosystem and grids
- Playwright: auto-waiting, browser contexts, tracing, network control
- Playwright bundles Chromium, Firefox and WebKit
- Choose based on team language, existing suite and needs
- Both can run in CI and in parallel
Model answer
Selenium is the long-standing standard. It uses the W3C WebDriver protocol, supports many languages such as Java, Python and C#, works with real branded browsers and has a huge ecosystem including Selenium Grid and cloud device providers. Selenium 4 also adds WebDriver BiDi for events. Playwright is newer and was designed for modern web apps. It auto-waits for elements, has web-first assertions, lightweight browser contexts for isolation, network mocking and an excellent trace viewer, and it ships Chromium, Firefox and WebKit. For a new web project in TypeScript or Python I usually choose Playwright because tests are faster to write and less flaky. I would keep Selenium when a company has a large working suite, needs a language Playwright does not support, or relies on an existing grid setup. The best tool also depends on team skills.
Can you answer it under time pressure?
Take a timed easy round and get scored on every answer.
More easy Automation Test Engineer questions
- Why do teams automate tests, and what should not be automated?
- Explain the Page Object Model and its benefits. Are there any downsides?
- What is the difference between implicit waits, explicit waits and auto-waiting?
- How do you run automated tests in a CI pipeline?
- When would you write an API test instead of a UI test?
- How do you choose locators for UI tests, and what makes a locator fragile?
- Explain the test pyramid. How does it guide what you automate?
- When you automate tests for a REST API endpoint, what do you check?
- What makes an automated test good?