Skip to content
TargetQA

Automation Tools

Playwright Interview Questions & Answers

Playwright interview questions covering locators, auto-waiting, fixtures, projects, parallelism, API testing, network mocking and debugging with the trace viewer.

50 questions17 Beginner20 Intermediate13 Advanced

Interview Questions

Showing 15 of 50 questions

  1. Playwright is an open-source end-to-end testing framework from Microsoft that drives Chromium, Firefox and WebKit through a single API. Teams pick it for built-in auto-waiting, a first-class test runner, parallelism, tracing and network control without extra libraries.

  2. A Browser is a launched browser instance, a BrowserContext is an isolated incognito-like session with its own cookies and storage, and a Page is a single tab inside a context. @playwright/test creates a fresh context and page per test by default.

  3. Before each action Playwright runs actionability checks, waiting until the element is attached, visible, stable, enabled and receives events. Web-first assertions like toBeVisible also retry until they pass or time out.

  4. Web-first assertions are async matchers on locators or pages, like expect(locator).toHaveText(), that retry until the condition holds. They remove flakiness caused by asserting on a value read once.

  5. I configure testDir, baseURL, timeouts, retries, workers, reporters, trace/screenshot/video settings and projects for each browser or device. Environment-specific values come from env variables.

  6. For iframes I use page.frameLocator() or locator.contentFrame() and then locate inside it. For new tabs I wait for the context's 'page' event while triggering the click.

  7. Fixtures provide setup and teardown for what a test needs, like page or request, and are injected by name. I extend the base test with test.extend to add page objects, authenticated pages or test data.

  8. Each page class takes a Page in the constructor, exposes locators as readonly properties and user-level methods like login(). Assertions mostly stay in tests, and page objects are injected through fixtures.

  9. I log in once in a setup project, save the session with storageState, and have other projects reuse that file. Tests start already authenticated, which is faster and less flaky.

  10. I use page.route() with a URL pattern and then route.fulfill(), route.abort() or route.continue(). route.fetch() lets me modify a real response before returning it.

  11. Yes, the request fixture (APIRequestContext) sends HTTP requests and works with the same expect assertions. I use it for pure API tests and to seed or clean data before UI tests.

  12. Playwright runs test files in parallel across worker processes, and fullyParallel also parallelizes tests within a file. Sharding splits the suite across machines with --shard=1/4, and merge-reports combines the blob reports.

  13. Locally I use UI mode (--ui) or --debug with the Inspector, and page.pause(). For CI failures I open the trace with npx playwright show-trace, which shows DOM snapshots, network, console and each action.

  14. I download the trace, screenshot and video from the CI artifacts and compare against a local run. Typical causes are timing under slower CPUs, different viewport or headless behavior, environment data, or tests sharing state under higher parallelism.