Back to interview questions

100+ Playwright Interview Questions and Answers

100+ Playwright Interview Questions and Answers

Explore 120 Playwright interview questions and answers on locators, assertions, fixtures, API mocking, browser testing, CI sharding and flaky test diagnosis.

Explore 120 Playwright interview questions and answers on locators, assertions, fixtures, API mocking, browser testing, CI sharding and flaky test diagnosis.

By

Team Sherlock.sh

Add Sherlock as a preferred source on Google

Playwright interviews should test whether candidates can build reliable end-to-end checks that reflect how people use a web application. A strong candidate can explain what makes a locator stable, which event proves an action succeeded, and how to investigate a failing test without making it less useful.

These 120 Playwright interview questions progress from browser contexts, locators and assertions to fixtures, mocked networks, parallel CI and production-like regression testing. The examples use Playwright Test with TypeScript and focus on authorized test environments and synthetic data.

How can you tell whether a candidate understands the Playwright test they just proposed?

Ask them to explain how they would diagnose a wrong-row click or verify that a successful UI message corresponds to a durable write. In remote interviews, Sherlock AI can help reviewers examine evidence of possible AI-assisted cheating, deepfakes, impersonation or other unauthorized assistance alongside that technical reasoning.

Playwright Interview Questions

Choose questions based on whether the role writes individual scenarios, owns testing for a product area or operates a large end-to-end suite.

Playwright Interview Questions for Beginners

Start with browser control, selectors, assertions and basic runner configuration.

  1. What is Microsoft Playwright?

  2. Which browsers can Playwright run tests against?

  3. What is the difference between Playwright and Playwright Test?

  4. What is a Playwright browser context?

  5. What is the difference between a browser, a context and a page?

  6. How do you write a basic Playwright test?

  7. What is a locator in Playwright?

  8. Why prefer getByRole for many Playwright tests?

  9. When should you use getByLabel?

  10. When is getByTestId a good choice?

  11. What is locator strictness in Playwright?

  12. How do you scope a Playwright locator to a component?

  13. What is Playwright auto-waiting?

  14. Which checks does Playwright use for a typical locator click?

  15. What is a web-first assertion?

  16. What is the difference between toBeVisible and isVisible?

  17. How do you wait for navigation in Playwright?

  18. What is the difference between page.goto and clicking a link?

  19. How do you fill a text input in Playwright?

  20. How do you select a value from a native dropdown?

  21. How do you interact with elements inside an iframe?

  22. How do you test a popup or new tab?

  23. How do you handle a JavaScript dialog in Playwright?

  24. How do you check an uploaded file in Playwright?

  25. How do you verify a download in Playwright?

  26. How do you run Playwright tests in headed mode?

  27. What is Playwright UI mode useful for?

  28. How can you use Playwright code generation responsibly?

  29. What are Playwright fixtures?

  30. What do beforeEach and afterEach do in Playwright Test?

  31. What is a Playwright project?

  32. What is baseURL in Playwright configuration?

  33. What is the Playwright webServer configuration?

  34. How do screenshots help in a Playwright failure?

  35. What is the Playwright Trace Viewer?

  36. What are retries in Playwright Test?

  37. What is the difference between a test timeout and an assertion timeout?

  38. What does Playwright’s mobile emulation change?

  39. How do you select specific tests in Playwright?

  40. How do you know a Playwright test has verified the right thing?

Playwright Interview Questions for Intermediate

Move into reusable fixtures, synchronization, network mocking and parallel execution.

  1. How do Playwright locators recover from a rerender?

  2. How should you test a changing list in Playwright?

  3. What does locator.filter help you express?

  4. When would you use locator.press instead of click?

  5. What is an accessible name and why does it matter for Playwright?

  6. Why avoid fixed sleeps in Playwright tests?

  7. Why is networkidle often a poor readiness signal?

  8. How do you use waitForResponse without an event race?

  9. How do you handle app state that changes outside the browser?

  10. How do you navigate and wait for a single-page app transition?

  11. How should you set up signed-in state for Playwright tests?

  12. When should Playwright tests use one account per worker?

  13. What should you know about sessionStorage in Playwright authentication setup?

  14. How do you create a custom Playwright fixture?

  15. How do test-scoped and worker-scoped fixtures differ?

  16. How can you use Playwright’s APIRequestContext for setup?

  17. How does route.fulfill support testing?

  18. How do you choose between mocking and a real backend in Playwright?

  19. How can network routing change Playwright test behavior?

  20. How do you use HAR files in Playwright responsibly?

  21. How do you configure a controlled time-dependent browser test?

  22. What is Playwright’s test step feature for?

  23. When should a Playwright helper become a page object?

  24. How should you organize Playwright configuration for multiple environments?

  25. How do Playwright project dependencies work?

  26. What is the difference between workers and shards in Playwright?

  27. How does fullyParallel affect Playwright execution?

  28. When should you use serial tests in Playwright?

  29. How does Playwright reset a worker after a test failure?

  30. How should you use screenshots for visual regression tests?

  31. What are screenshot snapshots versus accessibility snapshots?

  32. How do you test keyboard focus in Playwright?

  33. How do you test accessibility beyond role locators?

  34. How do you safely parallelize test data creation?

  35. How should a Playwright suite handle environment secrets?

  36. How can a Playwright test collect browser console errors?

  37. How do you test file uploads without relying on the operating system dialog?

  38. How do you test forms that have asynchronous validation?

  39. What is the purpose of Playwright reporters and attachments?

  40. How do you decide if a test assertion belongs at the UI or API layer?

Playwright Interview Questions for Experienced

Assess advanced debugging, coverage design, CI reliability and production-like testing.

  1. How would you investigate a Playwright test that fails only in CI?

  2. How do you distinguish a flaky test from a flaky product?

  3. Which measurements help track Playwright suite stability?

  4. How would you handle a flaky critical checkout test?

  5. How should CI capture traces without excessive overhead?

  6. What would you put in a Playwright failure evidence bundle?

  7. How would you reduce Playwright test suite duration safely?

  8. How would you decide Playwright worker count in CI?

  9. How do you balance shard size when test durations differ widely?

  10. How would you prevent cross-shard fixture collisions?

  11. How do you merge Playwright reports across distributed jobs?

  12. How do you define a practical browser test matrix?

  13. How would you test a bug that appears only on real iOS Safari?

  14. How do you make visual baselines reliable across operating systems?

  15. When is a screenshot diff the wrong assertion?

  16. How would you test loading, empty, failure and retry states deterministically?

  17. How would you test optimistic UI without a race-prone sleep?

  18. How do you test cancellation of an in-flight browser request?

  19. How do you verify a single user action did not create duplicate records?

  20. How should you test permission boundaries with Playwright?

  21. How do you test two-user collaboration using Playwright?

  22. How would you test real-time updates with WebSockets?

  23. How do you test offline or poor-network behavior?

  24. How do you test service worker behavior in a Playwright suite?

  25. How do you test an app that uses third-party sign-in?

  26. How do you test payments safely with Playwright?

  27. How do you choose timeouts for a large Playwright suite?

  28. How would you fix a noisy Playwright polling assertion?

  29. How do you detect that a test passes for the wrong reason?

  30. How do you avoid hiding bugs behind a Playwright wrapper?

  31. What is a good strategy for updating brittle locators at scale?

  32. How would you introduce Playwright to a product without existing end-to-end tests?

  33. How do you migrate an existing Selenium suite to Playwright?

  34. How would you keep end-to-end tests separate from load tests?

  35. How do you review Playwright coverage for a release?

  36. How do you make end-to-end test artifacts privacy-safe?

  37. How would you validate a Playwright upgrade?

  38. How would you recover after a Playwright run leaves test data behind?

  39. What makes a good Playwright code review?

  40. What senior Playwright interview exercise reveals practical judgment?

Playwright Interview Questions and Answers

Each answer explains what the feature guarantees, illustrates it with an application test and points out a common failure mode or a relevant trade-off.

Playwright Interview Questions and Answers for Beginners

Review the basic browser, locator and runner model with practical use cases.

1. What is Microsoft Playwright?

Playwright is a browser automation library used for end-to-end web testing. Playwright Test is its Node.js test runner, with fixtures, assertions, retries and reporting built around that browser control.

A checkout test can interact with a staging storefront through the browser and assert a visible confirmation. Pure calculations should still have fast unit tests; browser coverage is for behavior that depends on the integrated application.

2. Which browsers can Playwright run tests against?

Playwright supports Chromium, Firefox and WebKit, with supported channels for some branded browsers. These projects expose engine differences, not every possible browser version and operating-system combination.

A team can exercise its essential workflow across the three engines while using a smaller project for rapid pull-request feedback. WebKit coverage on CI is valuable, but it is not a substitute for every real Safari device configuration.

3. What is the difference between Playwright and Playwright Test?

Playwright exposes browser, context, page and automation APIs. Playwright Test adds a test runner, fixtures, assertions, configuration and artifacts so scenarios can run repeatedly and produce actionable results.

Use the runner for a team regression suite with CI reports. A small diagnostic script can use the library directly, but then its creator owns lifecycle, failure reporting and cleanup.

4. What is a Playwright browser context?

A context is an isolated browser session within a browser instance. Its own cookies, storage and permissions make it a practical isolation boundary for tests.

Two contexts can sign in as different test users without sharing a cookie jar, then access the same application. Their server-side records can still collide, so context isolation does not remove the need for unique fixtures.

5. What is the difference between a browser, a context and a page?

A browser is the launched or connected browser instance, a context is an isolated session, and a page represents a tab or similar browsing surface within a context.

Use two pages in one context for a test of a signed-in popup. Use two contexts to simulate an administrator and a viewer who must not share authentication or storage.

6. How do you write a basic Playwright test?

Declare a test, receive fixtures such as page, perform actions through locators, and verify an observable outcome with expect. Keep setup and the intended behavior clear in the test name.

A sign-in scenario can visit a test environment, fill labeled controls and assert the account heading. Clicking Submit without checking the resultant state only establishes that an action was attempted.

import {test, expect} from '@playwright/test';

test('shows the seeded order', async ({page}) => {
  await page.goto('/orders');
  await expect(page.getByRole('heading', {name: 'Orders'})).toBeVisible();
  await expect(page.getByRole('row', {name: /Order 481/})).toBeVisible();
});
import {test, expect} from '@playwright/test';

test('shows the seeded order', async ({page}) => {
  await page.goto('/orders');
  await expect(page.getByRole('heading', {name: 'Orders'})).toBeVisible();
  await expect(page.getByRole('row', {name: /Order 481/})).toBeVisible();
});
import {test, expect} from '@playwright/test';

test('shows the seeded order', async ({page}) => {
  await page.goto('/orders');
  await expect(page.getByRole('heading', {name: 'Orders'})).toBeVisible();
  await expect(page.getByRole('row', {name: /Order 481/})).toBeVisible();
});

7. What is a locator in Playwright?

A locator describes how to find an element when an operation runs. Its query can resolve again as the application changes, rather than holding one fixed DOM element across updates.

If React replaces a checkout button during rerender, a locator still refers to the current matching button. A previously captured element handle may refer to a detached node instead.

8. Why prefer getByRole for many Playwright tests?

A role locator expresses how a control is exposed to accessibility APIs and can include its accessible name. This tends to survive CSS changes and encourages tests to follow user-visible semantics.

A button named Save changes is easier to maintain than a selector for the third div in a row. The role locator is not a complete accessibility audit; it checks that one test path can find the expected semantics.

9. When should you use getByLabel?

Use it for form controls distinguishable by an associated label. It expresses a human-readable field identity and avoids coupling the test to transient class names or generated element IDs.

Find the work email input by its label rather than an internal field identifier. If several forms repeat the label, scope the locator to the intended form instead of depending on document order.

10. When is getByTestId a good choice?

Use a stable test ID when a meaningful semantic locator is ambiguous, dynamic or deliberately unavailable. Treat the ID like a small contract between the product and test suite.

A complex visual canvas may expose a stable widget identifier while its visible labels change. For ordinary buttons, a role and name are usually more representative of how a user finds the action.

11. What is locator strictness in Playwright?

Actions that require one element throw if the locator matches more than one. The failure exposes an ambiguous test rather than guessing which matching target should receive the action.

If a page and a modal both contain Save, scope to the named dialog before selecting its button. Using first just silences the ambiguity unless order is a defined and tested part of the UI.

12. How do you scope a Playwright locator to a component?

Start with a meaningful container and chain locators or use filters to narrow the target. Prefer relationships and user-visible identity over a wide selector followed by a numeric index.

Find the row containing the order number and then its Cancel button. If sorting changes, the test still addresses the intended order rather than canceling whichever row moved to the chosen position.

const row = page.getByRole('row').filter({
  has: page.getByRole('cell', {name: 'Order 481', exact: true}),
});
await row.getByRole('button', {name: 'View details'}).click();
await expect(page.getByRole('heading', {name: 'Order 481'})).toBeVisible();
const row = page.getByRole('row').filter({
  has: page.getByRole('cell', {name: 'Order 481', exact: true}),
});
await row.getByRole('button', {name: 'View details'}).click();
await expect(page.getByRole('heading', {name: 'Order 481'})).toBeVisible();
const row = page.getByRole('row').filter({
  has: page.getByRole('cell', {name: 'Order 481', exact: true}),
});
await row.getByRole('button', {name: 'View details'}).click();
await expect(page.getByRole('heading', {name: 'Order 481'})).toBeVisible();

13. What is Playwright auto-waiting?

Before supported actions, Playwright waits for applicable actionability conditions such as visibility, stability, an enabled state and receipt of pointer events. The exact checks depend on the action.

A button covered by a loading overlay should not be clicked merely because it exists in the DOM. Auto-waiting can wait for it to become usable; it does not know whether the server accepted the following operation.

14. Which checks does Playwright use for a typical locator click?

For a normal click, the locator must resolve to one element and the relevant actionability checks include visibility, stability, receiving events and being enabled. The action times out when prerequisites remain unmet.

If a cookie dialog intercepts clicks, fix the scenario or establish the intended dialog flow. A forced click may hide a genuine issue and is not the default way to work around transient UI state.

15. What is a web-first assertion?

A web-first assertion retries a browser-facing condition until it passes or reaches its assertion deadline. It is usually more appropriate than sampling the current value once for a changing interface.

After adding a product, await an assertion that the cart count displays one. Comparing a one-time immediate text read can fail before a render even when the application behaves correctly.

16. What is the difference between toBeVisible and isVisible?

toBeVisible is a retrying assertion on the locator. isVisible reads the current state without waiting for it to converge, useful when the test genuinely needs a snapshot decision.

If an asynchronous notification should appear, use the assertion. If inspecting which of two already-settled states the page is in for diagnostics, a snapshot read may be appropriate.

17. How do you wait for navigation in Playwright?

Assert the intended URL or the user-visible destination state, using an explicit wait when coordination requires it. Choose the signal that proves the business action rather than an arbitrary sleep.

After sign-in, expect the dashboard heading and, if path matters, the dashboard URL. A finished navigation alone does not prove a user can load the content or that required data was persisted.

18. What is the difference between page.goto and clicking a link?

page.goto starts a browser navigation to a URL directly. Clicking a link verifies a particular UI affordance and its behavior, which may involve a client transition or a new browsing surface.

Open a dashboard URL directly to test deep linking. In a separate navigation test, click the dashboard link and assert the result so a broken link is not bypassed by the test setup.

19. How do you fill a text input in Playwright?

Use a locator for the intended field and fill it with the desired text. Choose more granular keyboard operations only when behavior depends on the sequence of individual key events.

A standard name field can use fill. An autocomplete that responds to each typed character may require sequential typing and a visible assertion that the right suggestion is selected.

20. How do you select a value from a native dropdown?

Use selectOption for a real HTML select element, picking by appropriate value or label. A custom combobox needs the interactions and assertions that reflect its role and behavior.

For a native country picker, select the intended label. For a searchable custom picker, click the combobox, type a term and choose an option instead of pretending it is a native control.

21. How do you interact with elements inside an iframe?

Use frameLocator to scope the element lookup into the intended frame. A normal page locator does not automatically cross a frame boundary.

A staging payment widget can be located through its named frame and tested with a sandbox input. Keep actual payment details out of tests and isolate third-party availability when it is not the behavior under review.

22. How do you test a popup or new tab?

Register the relevant page or context event before triggering the action that opens it, then await the returned page and assert its content. Registering afterward can race with the event.

Before clicking View receipt, start waiting for the page’s popup event. Once it opens, verify the receipt reference and close the popup when it no longer belongs to the scenario.

const popupPromise = page.waitForEvent('popup');
await page.getByRole('link', {name: 'View receipt'}).click();
const receipt = await popupPromise;
await expect(receipt.getByRole('heading', {name: 'Receipt'})).toBeVisible();
const popupPromise = page.waitForEvent('popup');
await page.getByRole('link', {name: 'View receipt'}).click();
const receipt = await popupPromise;
await expect(receipt.getByRole('heading', {name: 'Receipt'})).toBeVisible();
const popupPromise = page.waitForEvent('popup');
await page.getByRole('link', {name: 'View receipt'}).click();
const receipt = await popupPromise;
await expect(receipt.getByRole('heading', {name: 'Receipt'})).toBeVisible();

23. How do you handle a JavaScript dialog in Playwright?

Register the dialog handler before the triggering action if you need to inspect or choose the dialog result. A listener must handle the dialog, or the operation can stall waiting for the modal response.

For a confirmation test, assert the message and accept in the handler, then verify the expected application state. If the scenario is cancellation, dismiss and verify the record remains unchanged.

24. How do you check an uploaded file in Playwright?

Provide a controlled fixture through the supported file input or file chooser API, then assert the user-visible or server-backed result. File selection alone does not prove a successful upload.

A CSV-import test can use a small synthetic fixture and verify the displayed count. Include a malformed fixture in a separate test and check the error rather than sending real customer records through CI.

25. How do you verify a download in Playwright?

Start waiting for the download event before clicking, then inspect the suggested filename or save it into the test’s output area for content verification. Check the property that matters to the user.

A report export test should verify a known header and record when correctness matters. Merely seeing the download event will not catch an empty file or a report generated for the wrong fixture.

26. How do you run Playwright tests in headed mode?

Run the selected test with the runner’s headed option to see browser interaction. Headed is useful for diagnosis, but headed success does not establish that the default CI configuration is reliable.

Keep the same route, data and test project when comparing headed and headless results. Otherwise a change in viewport, permissions or environment can be mistaken for a browser display issue.

27. What is Playwright UI mode useful for?

UI mode presents an interactive view of test runs and diagnostics, making it useful for local development and investigation. It is not an alternative to a reproducible command-line CI run.

Use it to inspect the steps around an unexpected failure or to run a small subset while editing. Confirm the final fix in the project and execution mode that failed in CI.

28. How can you use Playwright code generation responsibly?

The recorder can suggest actions and locators from an interaction. Treat the generated output as a starting point: remove unnecessary steps, add assertions and improve test data and selector choices.

A recorded signup flow may include incidental clicks and exact values from one session. Replace those with explicit fixture values and checks for the real outcome before committing it.

29. What are Playwright fixtures?

Fixtures provide setup, reusable dependencies and teardown to tests. Built-in fixtures include page and browser-related controls, and custom fixtures can model application resources.

A synthetic account fixture can create its record and clean it up after the test. This keeps test bodies focused and avoids sharing mutable setup accidentally across unrelated scenarios.

30. What do beforeEach and afterEach do in Playwright Test?

They run setup or teardown around individual tests within their scope. They are useful for simple repeated steps, but fixtures often give clearer dependency ownership and cleanup for reusable resources.

A beforeEach hook can visit a consistent starting path. Creating external records is often better in a fixture that returns their IDs and ensures cleanup is paired with creation.

31. What is a Playwright project?

A project is a named configuration grouping, useful for browsers, device profiles, environments and setup dependencies. Projects allow the same tests to run under different intended conditions.

Define Chromium desktop and mobile viewport projects when the behavior differs meaningfully. Avoid multiplying every test by every combination if identical paths do not add useful coverage.

32. What is baseURL in Playwright configuration?

baseURL lets tests use relative URLs resolved against a configured origin. It keeps test procedures portable while making the environment selection explicit.

A test can call goto with /orders in local and staging projects. Set safeguards so destructive test fixtures cannot be pointed at production by a mistaken environment value.

33. What is the Playwright webServer configuration?

webServer can start an application command and wait for it to become available before test execution. Its lifecycle and reuse options should fit local and CI environments deliberately.

Reuse an already-running dev server locally if appropriate, but start a known build in CI. A process that accepts connections before migrations finish can still require a better readiness signal.

34. How do screenshots help in a Playwright failure?

Screenshots show visible UI and layout at capture time, which can reveal overlays, wrong routes or rendering defects. They do not reveal every network, DOM or timing detail that caused the failure.

A screenshot of a spinner explains why a confirmation was absent but not why the request stalled. Pair it with a trace or correlated server log when the cause is not visible.

35. What is the Playwright Trace Viewer?

Trace Viewer shows recorded test actions and diagnostic evidence such as snapshots, network activity and console records where available. It helps reconstruct a failure without relying only on the last screenshot.

Inspect which element matched, what the page displayed before the click and whether a response arrived. Treat traces as potentially sensitive if tests record cookies, payloads or user data.

36. What are retries in Playwright Test?

Retries rerun failed tests according to runner configuration; a failed test that passes on retry is reported as flaky. They are a diagnostic and resilience tool, not a fix for an unreliable scenario.

A retry can collect a trace or reveal nondeterminism. Track how often first attempts fail; otherwise a green final run can hide a growing suite reliability problem.

37. What is the difference between a test timeout and an assertion timeout?

A test budget bounds overall execution, with other runner scopes having their own timing rules. An assertion timeout bounds how long a specific expected condition is retried; increasing one does not automatically diagnose the other.

A slow account setup may consume the test budget before a visibility assertion can help. Time the setup and action separately before raising global limits across the whole suite.

38. What does Playwright’s mobile emulation change?

A device profile can set parameters such as viewport, touch capability and user agent to simulate aspects of a mobile browsing surface. It does not emulate every hardware or operating-system behavior.

Use a narrow touch viewport to test menu layout, then separately validate a device-specific issue on representative hardware. Some browser gestures and performance characteristics are not captured by desktop emulation.

39. How do you select specific tests in Playwright?

Filter by file, project, title patterns or configured tags as appropriate. Keep intentional selection separate from an accidental test-only marker committed to the suite.

Run a single checkout scenario while diagnosing it, then run its project or relevant regression set. Configure CI to reject focused-only tests so unrelated coverage is not silently skipped.

40. How do you know a Playwright test has verified the right thing?

The assertion should match a user-visible or business outcome and fail when the expected behavior is deliberately broken. Actions and successful HTTP responses alone often verify only an intermediate step.

After a refund, verify the intended order status and financial fixture state rather than only the notification toast. If the toast can appear despite a failed write, it is not sufficient evidence by itself.

Playwright Interview Questions and Answers for Intermediate

Review the implementation details that make tests more deterministic, maintainable and useful.

41. How do Playwright locators recover from a rerender?

A locator describes a query evaluated for the current operation and can resolve a replacement element. It does not guarantee the replacement still has the same business identity if the selector was underspecified.

Use a stable order number when finding a row after a refresh. A selector for the first row may keep clicking successfully while silently targeting a different order after the table changes.

42. How should you test a changing list in Playwright?

Assert the intended count, item sequence or specific entries with a retrying assertion, depending on the contract. Avoid indexing a list before it has reached the intended result or after unrelated rows can reorder.

A filtered results list can assert the two expected names rather than first counting and then reading independent snapshots. If order is not contractual, use assertions that test membership without inventing an order requirement.

43. What does locator.filter help you express?

Filters narrow a locator by contextual text or another relevant descendant relationship. This is useful when multiple elements have the same visible control names but distinct surrounding identities.

Filter a collection of cards to the one containing a matching product heading, then find its Add button. Verify text matching is exact or sufficiently specific when similar product names coexist.

44. When would you use locator.press instead of click?

Use keyboard operations when the feature’s behavior is explicitly keyboard-driven, such as navigation, focus, shortcuts or an accessible disclosure interface. Click remains appropriate for pointer-driven scenarios.

A listbox keyboard test can focus the control, press ArrowDown and assert the active choice, then press Enter to commit. A click-only equivalent would not catch a broken keyboard handler.

45. What is an accessible name and why does it matter for Playwright?

An accessible name identifies a control to assistive technologies and may come from visible text, a label or another supported naming mechanism. A role locator can use it even when the visual presentation differs.

An icon-only control needs a suitable name such as Remove item. If a meaningful role/name locator cannot find it, check the application’s semantics before switching to a brittle CSS selector.

46. Why avoid fixed sleeps in Playwright tests?

A fixed sleep neither proves readiness nor adapts to changes in timing. Target an observable condition, such as an enabled control, a settled value or a relevant server response, within a bounded timeout.

A one-second wait before choosing search results fails on a slower CI worker and wastes time on a faster one. Assert the exact expected result and let the runner retry until the product reaches it.

47. Why is networkidle often a poor readiness signal?

Network activity may continue because of telemetry, live connections or background refresh even when the UI is ready. Conversely, a quiet network does not prove that the expected element or data state exists.

For a catalog page, assert the principal heading and known seeded result. Do not let analytics requests keep a checkout test waiting, or treat an idle missing page as a successful load.

48. How do you use waitForResponse without an event race?

Register the wait before triggering the interaction. Match enough information, such as method and exact endpoint path, that an unrelated request cannot satisfy it. Then assert the behavior visible to the user if the response is not the final contract.

To diagnose a save, begin waiting for the POST to the specific settings route and click Save. Check the response status and persistent value rather than matching any successful background request.

const saved = page.waitForResponse(response => {
  const url = new URL(response.url());
  return url.pathname === '/api/settings' && response.request().method() === 'POST';
});
await page.getByRole('button', {name: 'Save settings'}).click();
expect((await saved).ok()).toBeTruthy();
await expect(page.getByRole('status')).toHaveText('Settings saved');
const saved = page.waitForResponse(response => {
  const url = new URL(response.url());
  return url.pathname === '/api/settings' && response.request().method() === 'POST';
});
await page.getByRole('button', {name: 'Save settings'}).click();
expect((await saved).ok()).toBeTruthy();
await expect(page.getByRole('status')).toHaveText('Settings saved');
const saved = page.waitForResponse(response => {
  const url = new URL(response.url());
  return url.pathname === '/api/settings' && response.request().method() === 'POST';
});
await page.getByRole('button', {name: 'Save settings'}).click();
expect((await saved).ok()).toBeTruthy();
await expect(page.getByRole('status')).toHaveText('Settings saved');

49. How do you handle app state that changes outside the browser?

Use bounded polling against a supported test-facing signal or API when browser assertions cannot express the expected result. Evaluate a read-only predicate repeatedly; do not repeat mutations inside the poll.

A job can be started once through the UI, then polled until its seeded ID reaches completed. Repeating the start action inside the assertion could create duplicates and hide the very bug being tested.

50. How do you navigate and wait for a single-page app transition?

Use the observable route change and target UI for the intent. In a client-routed app the document may not reload, so a page load event can be irrelevant.

Click Orders, assert the URL if it is part of the requirement, and check the Orders heading and a known result. If a failed transition still updates the address, the content assertion helps distinguish routing from rendering.

51. How should you set up signed-in state for Playwright tests?

Use a setup step or fixture to establish authentication in a permitted test environment, then reuse storage state only where it is safe. Keep the stored file out of source control and protect it as a credential-bearing artifact.

A read-only suite can start from one shared test login if it cannot mutate shared state. Tests that update preferences or ownership typically need distinct accounts or reset data each run.

52. When should Playwright tests use one account per worker?

Use distinct worker accounts when tests modify server-side account state and parallel workers must not interfere. Derive a stable allocation from the execution context and maintain safeguards across multiple CI jobs.

Preferences and access settings should not race on one user. Include the run or shard in the account namespace because two CI jobs can have the same worker-local index.

53. What should you know about sessionStorage in Playwright authentication setup?

Do not assume storageState automatically saves every browser storage mechanism. In particular, sessionStorage needs a deliberate setup strategy if the application relies on it; prefer supported login mechanisms where practical.

A test might authenticate successfully during setup but lose a session value in a fresh context. Diagnose which storage the app uses, avoid broad capture of sensitive data and initialize only the authorized test state required.

54. How do you create a custom Playwright fixture?

Extend the test object with named fixtures and provide the resource to the test through use. Place cleanup after use, and declare dependencies so startup and teardown happen in the right order.

A ticket fixture can generate a unique record, hand its ID to the scenario, then clean up by that ID. Avoid shared mutable module variables that do not correspond to test or worker lifetime.

55. How do test-scoped and worker-scoped fixtures differ?

Test-scoped fixtures are recreated for each test; worker-scoped fixtures can be reused within one worker process. Worker reuse can save setup cost but makes isolation and cleanup assumptions important.

A test-specific record should not be reused across settings tests. A worker-scoped synthetic account can be useful if each test creates unique subordinate data and cleans up the state it changes.

56. How can you use Playwright’s APIRequestContext for setup?

Use API calls against a controlled test service to seed or inspect fixture data so browser tests concentrate on the workflow under test. Context sharing determines whether cookies are shared with the browser or isolated.

Create a draft through the API before testing its edit UI. Keep a separate UI creation test if that path matters, and ensure setup cannot operate against production through a misconfigured URL.

57. How does route.fulfill support testing?

It supplies a controlled response for a matched request so a test can exercise UI behavior without requiring the real dependency’s response. Assert the simulated outcome and keep separate real-service integration coverage.

Return an empty product list to test the empty state or a 503 to check retry messaging. A mocked success cannot prove that authentication, payloads and response schema match the deployed service.

await page.route('**/api/products', route => route.fulfill({json: []}));
await page.goto('/products');
await expect(page.getByText('No products found', {exact: true})).toBeVisible();
await page.route('**/api/products', route => route.fulfill({json: []}));
await page.goto('/products');
await expect(page.getByText('No products found', {exact: true})).toBeVisible();
await page.route('**/api/products', route => route.fulfill({json: []}));
await page.goto('/products');
await expect(page.getByText('No products found', {exact: true})).toBeVisible();

58. How do you choose between mocking and a real backend in Playwright?

Mock behavior when determinism or difficult error states are central, and use a real staging dependency when verifying integration contracts and durable effects. Label which assurance each test provides.

A retry panel can be tested with a guaranteed synthetic timeout. A real checkout smoke test should exercise a sandbox payment integration and verify the order persisted without risking a live charge.

59. How can network routing change Playwright test behavior?

Routing changes how intercepted requests are handled, and enabling routing can change HTTP cache behavior. Some service worker requests may evade normal interception depending on configuration and the request path.

If a cache test starts failing only after introducing broad routing, verify whether the harness disabled caching. Test service worker behavior separately or block service workers in tests whose contract specifically requires interception.

60. How do you use HAR files in Playwright responsibly?

Use captured HTTP archives as controlled replay fixtures when deterministic network responses help. Review and sanitize them, and understand how unmatched requests should behave so real external traffic is not accidental.

A small fixture can replay approved product catalog responses. Do not commit raw authentication headers or customer records, and add real integration tests to catch drift from the recorded contract.

61. How do you configure a controlled time-dependent browser test?

Use the application’s test hooks or Playwright’s supported Clock API to set or control browser time, then assert behavior with deterministic boundaries. Account for server time separately if it controls the business decision.

A countdown banner can be tested with simulated browser time. A reservation that expires in a backend database may also need an injected server clock; advancing one browser does not change the server’s time.

62. What is Playwright’s test step feature for?

Steps group related actions into named diagnostic units in reports and traces. They improve the meaning of failures but should not become an abstraction that hides the important operations or assertions.

Use steps such as Create draft, Publish staged fixture and Verify visibility when those stages matter. A name like Do everything makes the report less helpful than the individual actions it hides.

63. When should a Playwright helper become a page object?

Use a page object or focused component helper after there is a stable repeated interaction contract. Keep important assertions and scenario intent visible, and avoid a giant object that wraps every locator call.

A billing form helper can fill recurring fields while tests still assert declined versus accepted outcomes explicitly. If the helper also hides retries and selectors, diagnosing the real failure becomes harder.

64. How should you organize Playwright configuration for multiple environments?

Use typed shared defaults and explicit overrides for targets, projects, credentials and safety constraints. Validate the environment early, and keep secrets in the appropriate runtime configuration.

A staging project can exercise an external sandbox, while local projects start a development server and use synthetic fixtures. Explicit allowlists prevent a typo from mapping destructive setup tasks to production.

65. How do Playwright project dependencies work?

A project can declare that another project must run before its tests, allowing setup to be expressed in the runner’s fixture, reporting and trace model. Keep dependency outputs repeatable and safe to reuse.

An authentication setup project can generate a fresh state file for named browser projects. Do not rely on a stale local state file that happens to exist when a developer runs a subset of tests.

66. What is the difference between workers and shards in Playwright?

Workers are local runner processes executing test work, while sharding partitions a suite into separate invocations, often on different CI machines. Both affect data isolation and parallel execution design.

Four workers on each of three shards are not one shared pool with shared local files. Namespace fixtures by run and shard, and merge independently produced reports when CI finishes.

67. How does fullyParallel affect Playwright execution?

It allows tests within files to be scheduled in parallel where supported, instead of relying on the usual within-file sequencing. Tests must still be independent and safe to distribute across workers.

A file that assumes test B consumes a record created in test A can fail once distributed. Have each test create its own prerequisite or put genuinely inseparable steps into one scenario.

68. When should you use serial tests in Playwright?

Use serial groups sparingly for cases that genuinely cannot be isolated, understanding the skip and retry behavior of the group. Default to independent tests so one failure does not prevent unrelated evidence.

A multistep purchase is usually better as one test with named steps, while independent account actions get separate fixtures. Serial mode should not conceal a failing isolation design.

69. How does Playwright reset a worker after a test failure?

The runner can discard the failed worker and browser and start a fresh worker for later work or a retry. Code initialized once per worker may run again even during the same suite invocation.

An afterEach must not be assumed to repair an external database after every possible interruption. Use idempotent fixture cleanup and a scheduled sandbox cleanup process for artifacts a crashed worker can leave behind.

70. How should you use screenshots for visual regression tests?

Use stable data, consistent browser and operating-system conditions, and intentionally chosen regions or tolerances. Review baseline changes as product changes rather than updating snapshots merely to make CI green.

A product card screenshot can reveal layout shifts. Mask truly volatile values or freeze time where it is part of setup, but do not mask the content whose rendering is the very behavior under test.

71. What are screenshot snapshots versus accessibility snapshots?

Screenshots check pixels; accessibility-oriented snapshots check a representation of semantics and names. They detect different problems and neither replaces focused interaction assertions.

A modal can look identical while its accessible label disappears. Conversely the role can remain correct while styling clips the close button, so use the tool that corresponds to the failure risk.

72. How do you test keyboard focus in Playwright?

Perform the relevant keyboard interactions and assert focused controls and outcomes rather than only checking DOM order. Test how focus enters and exits modal or dynamic content.

Open a dialog with the keyboard, expect its intended initial control to focus, then close with Escape and verify focus returns to the trigger. Check both forward and backward navigation where it matters.

const trigger = page.getByRole('button', {name: 'Edit profile'});
await trigger.focus();
await page.keyboard.press('Enter');
const dialog = page.getByRole('dialog', {name: 'Edit profile'});
await expect(dialog.getByRole('textbox', {name: 'Display name'})).toBeFocused();
await page.keyboard.press('Escape');
await expect(dialog).toBeHidden();
await expect(trigger).toBeFocused();
const trigger = page.getByRole('button', {name: 'Edit profile'});
await trigger.focus();
await page.keyboard.press('Enter');
const dialog = page.getByRole('dialog', {name: 'Edit profile'});
await expect(dialog.getByRole('textbox', {name: 'Display name'})).toBeFocused();
await page.keyboard.press('Escape');
await expect(dialog).toBeHidden();
await expect(trigger).toBeFocused();
const trigger = page.getByRole('button', {name: 'Edit profile'});
await trigger.focus();
await page.keyboard.press('Enter');
const dialog = page.getByRole('dialog', {name: 'Edit profile'});
await expect(dialog.getByRole('textbox', {name: 'Display name'})).toBeFocused();
await page.keyboard.press('Escape');
await expect(dialog).toBeHidden();
await expect(trigger).toBeFocused();

73. How do you test accessibility beyond role locators?

Combine semantic checks, keyboard scenarios and accessibility tooling with manual review for behaviors automation cannot judge reliably. Choose testable requirements instead of assuming one scanner verifies all accessibility.

An automated rule may flag an unlabeled field. It cannot fully judge whether workflow instructions are understandable or whether assistive technology provides an effective end-to-end experience.

74. How do you safely parallelize test data creation?

Use unique identifiers tied to the run and test, place fixtures in isolated environments, and make cleanup selective and repeatable. Avoid global cleanup in one worker while another still needs the data.

Create orders under a synthetic tenant and delete only IDs the test owns. A broad reset of the staging database may make tests pass locally but race across concurrent CI runs.

75. How should a Playwright suite handle environment secrets?

Use scoped, short-lived or securely injected credentials for dedicated test accounts, and redact them from artifacts and logs. Treat browser storage files, traces and recorded requests as potentially sensitive.

Do not commit a logged-in state file or expose it as a public CI artifact. Limit retention and access to traces, and prefer synthetic accounts that cannot reach customer data.

76. How can a Playwright test collect browser console errors?

Subscribe to relevant console or page error events during the test and filter known noise carefully. Verify meaningful failures and attach concise diagnostics rather than failing on every third-party informational message.

A checkout test may fail when an unexpected uncaught exception prevents confirmation. Filter unrelated extension messages narrowly so a broad ignore rule cannot hide a new application regression.

77. How do you test file uploads without relying on the operating system dialog?

Set input files using the documented fixture path or supplied payload for the supported element, or await a file chooser when the UI requires it. Keep file contents and access scoped to the test.

Choose a small generated CSV and assert server-side rows or validation text. A native dialog click is unnecessary when the supported browser API can exercise the same application input path.

78. How do you test forms that have asynchronous validation?

Assert the intended intermediate and final user-facing states using deterministic data or a controlled dependency. Verify how stale responses and recent input changes are handled when the result can arrive out of order.

Type an existing username and then a free one, with the first lookup intentionally delayed. The final UI should correspond to the current field value rather than whichever response happened to arrive last.

79. What is the purpose of Playwright reporters and attachments?

Reporters summarize test status and evidence, while per-test attachments preserve specific diagnostic context. Choose artifacts that are actionable and safe to retain.

An HTML report can link a failing trace, screenshot and sanitized fixture identifiers. Publishing every console message and full network payload increases cost and privacy risk without necessarily improving triage.

80. How do you decide if a test assertion belongs at the UI or API layer?

Use the UI to prove user-visible behavior and the API or durable storage to prove business state when the interface alone is insufficient. Keep additional checks proportionate to the risk and use authorized test seams.

An order status label confirms the interface updated. A persisted test record and a unique payment reference can prove the state is actually durable and was not written twice.

Playwright Interview Questions and Answers for Experienced

Review scenarios that reveal how candidates balance coverage, speed and trustworthy evidence.

81. How would you investigate a Playwright test that fails only in CI?

Reproduce the CI browser, version, OS, command, data and worker count, then use traces to identify the first differing observation. Compare whether failure tracks execution environment, concurrency or application readiness.

If one worker passes but five fail, inspect shared state and resource limits before adding waits. If the trace shows a stable difference in fonts, align screenshot environments rather than changing the interaction test.

82. How do you distinguish a flaky test from a flaky product?

Find which component violates its contract. A test can be wrong by waiting for the wrong signal; the product can be nondeterministic if a real user can experience the same missing or wrong state.

If both test traces and manual reproduction show the confirmation sometimes never appears, fix the product. If only a raw immediate DOM read is unreliable, replace it with the intended retrying assertion.

83. Which measurements help track Playwright suite stability?

Track first-attempt pass rate, retries by test and project, time-to-triage, run duration and failure categories. Distinguish environmental failures from broken user behavior rather than counting every intermittent event equally.

A suite can still show a green overall pipeline while 15 percent of tests retry. A dashboard showing repeated failures in one flow or runner pool gives a clearer priority than a single final pass percentage.

84. How would you handle a flaky critical checkout test?

Preserve the signal and triage quickly with trace, known seed data and an independent reproduction. If quarantining is necessary, assign an owner, expiry and alternative coverage instead of suppressing the test indefinitely.

Keep a narrow blocking smoke scenario for checkout while a longer intermittently failing case is investigated. Verify outcomes against sandbox records; payment flows deserve evidence beyond final retry status.

85. How should CI capture traces without excessive overhead?

Record traces on appropriate retries or retain them on failures according to diagnostic need and artifact budget. Check what the trace contains and protect access before increasing retention.

Collect traces on the first retry for a large suite, then intentionally capture first-attempt failures for an investigation when reruns lose the original cause. Retain only what teams can use and secure.

86. What would you put in a Playwright failure evidence bundle?

Include the test and retry identifiers, project, deployed version, known fixture identifiers, concise error output, and suitable trace or screenshot links. Add request or server correlation IDs where available without leaking sensitive values.

If a test fails after a settings save, connect its trace to the matching server request. This lets owners distinguish an actual persistence failure from a frontend assertion made against stale data.

87. How would you reduce Playwright test suite duration safely?

Measure slow tests and setup costs, then remove redundant coverage, seed through supported shortcuts and shard appropriately. Preserve the scenarios needed for business confidence and measure reliability as speed improves.

If every test repeats five UI login steps, reuse secure state for compatible scenarios and keep focused login tests. Increasing parallelism without reducing backend bottlenecks may lengthen p95 completion time.

88. How would you decide Playwright worker count in CI?

Tune against browser memory, CPU, application and database capacity, and the intended latency budget. Run representative load with several worker counts, comparing first-attempt pass rate as well as duration.

On a small runner, doubling workers can trigger resource contention and slower screenshots. A staging database also has a concurrency ceiling; resetting all test timeouts does not increase its capacity.

89. How do you balance shard size when test durations differ widely?

Use timing data to identify skew and choose a sharding strategy compatible with runner grouping and test independence. Distributing by file alone can leave one slow spec dominating total time.

A long checkout file and many fast smoke files can produce uneven shards. Split independent scenarios or use supported fine-grained distribution, then measure total wall time and tail shard duration.

90. How would you prevent cross-shard fixture collisions?

Include a run identifier and shard or test identity in each mutable fixture, and make cleanup target owned resources. Ensure jobs that use the same environment cannot silently reuse another run’s accounts or records.

Two shards may both have a worker numbered zero. Generate separate tenant or order identifiers using the full CI run scope, and have cleanup reclaim only the matching namespace.

91. How do you merge Playwright reports across distributed jobs?

Have each shard emit compatible result artifacts, then collect them centrally with the supported merge workflow. Preserve browser, shard and build identities and make missing shards visible as incomplete coverage.

A merged report should not show an apparently complete green run if one machine failed to upload results. Check expected artifact count before making release decisions from the report.

92. How do you define a practical browser test matrix?

Prioritize supported browsers and devices using usage, impact and meaningful engine differences. Run a reduced suite for frequent changes and broader coverage at release or on a schedule if justified.

Critical payment and sign-in flows may run across all engines. A basic footer link does not need every viewport combination if those projects already cover the routing contract elsewhere.

93. How would you test a bug that appears only on real iOS Safari?

Reproduce on representative device and browser tooling, then decide which part can be covered by Playwright WebKit or mobile emulation. Keep device-specific validation when the underlying behavior is not faithfully emulated.

A narrow viewport can catch responsive layout regressions. A real keyboard viewport, operating-system interaction or browser version issue needs evidence from the affected configuration, not just a green desktop emulation test.

94. How do you make visual baselines reliable across operating systems?

Generate and compare intended baselines under a controlled browser and OS setup, including fonts, viewport and media settings. If platform differences are meaningful, keep appropriate baselines rather than blending dissimilar environments.

A Linux CI screenshot may rasterize text differently from macOS. Review known rendering differences with small tolerances where justified, and avoid tolerances broad enough to mask a real overlap.

95. When is a screenshot diff the wrong assertion?

A visual diff is a poor substitute when the requirement is semantic, behavioral or durable. Prefer role, value, keyboard or server-backed evidence for those guarantees, and use pixels when appearance is the contract.

A submit button can look correct while it never sends the required request. Conversely a tiny antialiasing change should not fail a business transaction test unless appearance was explicitly in scope.

96. How would you test loading, empty, failure and retry states deterministically?

Use controlled fixtures or selected mocked responses so the test can produce each intended state at will. Verify transitions and recovery, not merely static screenshots of each endpoint response.

Respond with a synthetic 503 on the first attempt and a known list on the next. Confirm a useful message, that one deliberate retry succeeds, and that the visible state reflects the expected records.

97. How would you test optimistic UI without a race-prone sleep?

Control the relevant request completion and assert the optimistic state before releasing the mocked or test-controlled response. Then verify reconciliation for both acceptance and failure.

A favorite button can change immediately while the request is held. Release a rejection and verify that the button returns to the prior state and that the user receives an accurate explanation.

98. How do you test cancellation of an in-flight browser request?

Use a controlled slow response and an observable test seam to distinguish cancellation, ignored results and visible state. Assert the final behavior required by the feature, not a specific transport mechanism unless it is contractual.

Navigate away from a search results panel while a request is open. Verify that old results cannot overwrite the new view; a canceled request in a trace alone does not establish that the UI handled all late responses.

99. How do you verify a single user action did not create duplicate records?

Track the operation using known fixture IDs and query an authoritative test-visible record or API after the UI action. Use a controlled failure or repeat that exercises the actual idempotency boundary.

Repeat an orders action after a synthetic lost response and assert that there is one order and one external sandbox reference. Counting button clicks does not prove that only one durable effect occurred.

100. How should you test permission boundaries with Playwright?

Use designated low-privilege and permitted test users in an authorized environment, asserting real business behavior and the absence of unauthorized changes. Pair with server-side authorization tests where appropriate.

A viewer should not see the edit control, and the server-side test suite should enforce the same access policy if the UI changes. Avoid real accounts and do not turn a UI regression suite into exploratory intrusion.

101. How do you test two-user collaboration using Playwright?

Create separate contexts with separate synthetic identities and a shared test resource. Coordinate actions through visible state and assert what each participant should see within an explicit consistency expectation.

Have editor A update a document and viewer B observe the new title. Verify identity-specific UI remains distinct, and remove only the resource created for that scenario during cleanup.

102. How would you test real-time updates with WebSockets?

Verify the user-visible update using an authorized test environment or a controlled application-owned feed. Separate the behavior of the interface from the delivery guarantees of the deployed service.

One context can create a test message while another observes its arrival. Use a separate scenario for reconnect and catch-up where the product promises those guarantees, not a shared arbitrary delay.

103. How do you test offline or poor-network behavior?

Use the supported browser context or application test controls to establish a known network condition, then assert degraded UI, recovery and durable state as appropriate. Do not assume test offline mode models every real connection problem.

An offline notes app might show a queued save and sync after connectivity returns. Verify the record is persisted once, and add separate latency or asymmetric failure scenarios when business behavior needs them.

104. How do you test service worker behavior in a Playwright suite?

Use a separate configuration where service workers are enabled and ensure the worker has actually taken control before testing its offline or cache behavior. Do not let network mocks change the behavior being evaluated.

A first navigation can install the worker while a later page is controlled. Verify cached assets and offline reload in their own tests, then use other isolated contexts for API response mocks.

105. How do you test an app that uses third-party sign-in?

Use an approved sandbox or supported fixture for routine scenarios, and reserve a small integrated path for the real provider contract where the team controls access. Avoid hard-coding credentials or depending on unsanctioned production flows.

Most account tests can start with scoped test sign-in state. A separate controlled sign-in test can verify the redirect and application session without making the entire suite dependent on one external service.

106. How do you test payments safely with Playwright?

Use a provider sandbox and synthetic payment fixtures, validate the test environment before requests, and assert both the UI result and the intended durable records. Never use real payment identifiers in test automation.

Include accepted and rejected sandbox cases and reconcile one test payment with one order. If a live endpoint is reachable due to configuration drift, the harness should fail before interacting with it.

107. How do you choose timeouts for a large Playwright suite?

Define time limits by scenario and subsystem based on representative measurements. Keep delays large enough for legitimate behavior but narrow enough to localize failures and expose regressions.

A report export that legitimately takes seconds can have a focused expectation budget. Raising the global timeout because of one slow staging service delays detection of unrelated selector mistakes.

108. How would you fix a noisy Playwright polling assertion?

Make the predicate narrow, read-only and tied to a meaningful observable state. Check the polling interval, completion deadline and underlying dependency load before increasing attempts.

Poll the status for one known job ID instead of listing all jobs on every iteration. If the expected state cannot occur when a prerequisite is missing, fail with a clear diagnostic instead of polling to the full deadline.

109. How do you detect that a test passes for the wrong reason?

Challenge it with a targeted application or fixture change that should make it fail. Ensure selectors identify the intended entity, event predicates match the intended request, and assertions prove the final result.

Remove the expected record from a seeded list while leaving another record with a similar title. If the test passes, narrow its matcher and add an assertion specific to the correct business entity.

110. How do you avoid hiding bugs behind a Playwright wrapper?

Keep wrappers small and purposeful. Avoid helpers that catch failures, retry arbitrary mutations or silently pick alternate locators, because they obscure what the user would actually experience.

A helper can supply a repeated navigation sequence with meaningful error context. It should not silently select another Save button if the intended one disappears after a redesign.

111. What is a good strategy for updating brittle locators at scale?

Prioritize frequently failing high-value tests, add semantic contracts where product markup supports them, and update shared components rather than replacing every selector indiscriminately.

Replace positional table selectors with row identity and named controls. In review, intentionally reorder the rows so the new locator demonstrates why it is more reliable. Then test a duplicate-looking row to guard against ambiguous matches.

112. How would you introduce Playwright to a product without existing end-to-end tests?

Start with a small set of high-impact scenarios using deterministic fixtures and a production-like environment. Set expectations for ownership, artifacts and failure response before expanding the matrix.

A good initial suite can cover sign-in, a core task and one important error path. Add wider scenarios after teams can reliably run and debug those tests instead of building hundreds of brittle recorded flows.

113. How do you migrate an existing Selenium suite to Playwright?

Map each test to the behavior and risk it covers, then rewrite high-value paths using locators, fixtures and retrying assertions rather than mechanically porting waits. Compare both suites during a bounded transition.

A legacy test that sleeps before saving can be replaced by a visible readiness assertion. Retire the old case only after the new test proves equivalent outcomes and is reliable in the target environment.

114. How would you keep end-to-end tests separate from load tests?

Use Playwright for user behavior through real rendering and use dedicated workload tools for large-scale throughput and concurrency. Coordinate representative browser checks during a load exercise if UX under load matters.

One browser trace can diagnose the effect of a slow backend during a load window. Launching thousands of browser instances just to generate simple API traffic measures runner resource usage more than the application’s real limits.

115. How do you review Playwright coverage for a release?

Map changes to business-critical journeys and failure modes, then confirm where each is exercised with appropriate data, browser or environment. Review uncovered paths and assign responsibility rather than equating test count with confidence.

A billing release may need sandbox refunds, a permission boundary and migration compatibility tests. A suite with many marketing screenshots says little about those risks, even if it takes longer to run.

116. How do you make end-to-end test artifacts privacy-safe?

Use synthetic data first, restrict artifact access, redact credentials and sensitive payloads, and set short intentional retention. Assume screenshots, traces and network records can retain more than their obvious output shows.

A screenshot can expose a user’s email, and a trace can include sensitive requests. Define what gets collected in each test environment and test redaction rather than relying on people to notice before sharing.

117. How would you validate a Playwright upgrade?

Read release notes for browser changes and deprecations, pin the runner and acceptable browser artifacts, then test a representative subset plus the full critical suite in CI. Distinguish meaningful product differences from baseline churn.

If WebKit behavior changes, inspect the actual interaction and failure trace before indiscriminately updating screenshots. Roll back or regenerate baselines only after understanding what the change represents.

118. How would you recover after a Playwright run leaves test data behind?

Use an inventory of test-owned records and a bounded cleanup process that confirms ownership and preserves anything unrelated. Make future fixture creation and cleanup idempotent and resilient to abrupt worker exit.

A run ID can identify stale synthetic orders in staging. Clean narrow scoped records after other active jobs finish, and alert the suite owner if artifacts repeatedly outlive their cleanup window.

119. What makes a good Playwright code review?

Check the user intent, locator semantics, readiness signals, assertions, isolation, authorization of test data and usefulness of diagnostics. Ask whether the test is both capable of catching the defect and reproducible when it fails.

A reviewer can inspect why a test uses a forced click, why it matches a broad response and how it cleans up. A passing run alone does not answer whether the check will protect the product.

120. What senior Playwright interview exercise reveals practical judgment?

Give a short failing scenario, a trace summary and a changed application behavior. Ask the candidate to identify the first divergence, propose the smallest useful fix and explain what evidence would confirm reliability.

A checkout test might intermittently select the wrong similarly named product after a redesign. A strong answer scopes by stable visible identity, checks the actual checkout outcome and verifies it under representative parallel execution.

Playwright Documentation and Further Reading

The official Playwright documentation below covers the runner, browser control, fixtures and diagnostic practices discussed in this guide. Match APIs and browser versions to the version installed by your project.

Team Sherlock.sh

Building fraud intelligence for live high-stake video interactions (financial discussions, hiring interviews, board meeting etc).

Catch candidate fraud before it costs you.

Sherlock AI helps you detect AI-assisted, proxy, and deepfake candidates, so every hiring decision is backed by evidence.

Ask AI about Sherlock.sh

Similar Posts