Basics
1. What is Playwright and how is it different from Selenium?
Playwright is a Node-first automation framework by Microsoft. It bundles browsers, auto-waits by default, supports API testing, and runs three engines (Chromium, Firefox, WebKit) with a single API — unlike Selenium which relies on external drivers.
2. Which browsers does Playwright support?
Chromium (and Chrome/Edge channels), Firefox, and WebKit (Safari's engine).
3. What language bindings does Playwright have?
TypeScript/JavaScript (primary), Python, Java, and .NET.
Locators & Waiting
4. Why prefer getByRole over CSS selectors?
Role-based locators are more stable and mirror how assistive tech sees the page, so they double as an accessibility check.
5. How does auto-waiting work?
Before every action Playwright verifies actionability (attached, visible, stable, enabled, receives events) and retries within the timeout — no manual sleep().
6. Difference between locator.click() and elementHandle.click()?
Locators are lazy and re-queryable; element handles are snapshots that can go stale. Always use locators.
Framework Design
7. How do you organise a Playwright project?
Pages/ for page objects, fixtures/ for custom test fixtures, data/ for test data, tests/ split by ui/api/e2e, and one central playwright.config.ts.
8. When would you avoid the Page Object Model?
For tiny throwaway suites, or when a shared component (not a page) is a better abstraction — favor composition over rigid POM.
9. How do you share login state across tests?
Log in once in global setup, save storageState to a JSON file, and reference it in playwright.config.ts under use.storageState.
CI/CD & Reporting
10. How do you speed up a slow Playwright suite in CI?
Enable fullyParallel, use --shard across a matrix, cache Playwright browsers, and disable video/trace on green runs (retain-on-failure).
11. How do you debug a failing CI run?
Enable trace: 'on-first-retry', upload the trace as an artifact, then open it locally with npx playwright show-trace trace.zip.
Get Playwright tutorials in your inbox
Weekly tips, real-world examples, and framework patterns – no spam, unsubscribe anytime.