Skip to content

Playwright interview questions — Medium

803 medium-level Playwright questions from our Automation Testing bank, each with the correct answer and an explanation of why it is correct.

What this covers

Playwright appears throughout Automation Testing interviews. At medium level, interviewers are typically checking that you have used it in practice: what you configured, what broke, and how you knew it worked. Work through these, then explain your answer out loud; the second part is what interviews actually test.

20 example questions

  1. 1. While onboarding a junior QA, you explain: Why are Playwright Locators preferred over $() handles?

    • A. Lazily re-resolved on each action, avoiding stale elements.correct
    • B. Handles auto-wait but locators don't.
    • C. Locators only work on inputs.
    • D. $() supports assertions, locators don't.

    Why: Locators are lazy and re-resolved at action time with auto-wait.

  2. 2. "Config entries that run the suite against multiple browsers or devices" — in Playwright, this describes which of the following?

    • A. Projects.correct
    • B. Trace: 'on-first-retry'.
    • C. Test.step().
    • D. Test.use().

    Why: projects: Config entries that run the suite against multiple browsers or devices.

  3. 3. "Retrying assertion that the element is visible" — in Playwright, this describes which of the following?

    • A. Npx playwright show-report.
    • B. FullyParallel.
    • C. Page.screenshot().
    • D. Expect(locator).toBeVisible().correct

    Why: expect(locator).toBeVisible(): Retrying assertion that the element is visible.

  4. 4. "Performs an actionability-checked click on the matched element" — in Playwright, this describes which of the following?

    • A. Locator.click().correct
    • B. Page.goto().
    • C. GetByTestId().
    • D. Trace: 'on-first-retry'.

    Why: locator.click(): Performs an actionability-checked click on the matched element.

  5. 5. "Creates a fresh isolated browser session" — in Playwright, this describes which of the following?

    • A. GetByText().
    • B. Npx playwright show-report.
    • C. Browser.newContext().correct
    • D. Locator.click().

    Why: browser.newContext(): Creates a fresh isolated browser session.

  6. 6. "Config option that records a trace only when a test is retried" — in Playwright, this describes which of the following?

    • A. Trace: 'on-first-retry'.correct
    • B. Page.screenshot().
    • C. Locator.fill().
    • D. FullyParallel.

    Why: trace: 'on-first-retry': Config option that records a trace only when a test is retried.

  7. 7. "Overrides fixtures/options such as viewport or locale for a test group" — in Playwright, this describes which of the following?

    • A. Test.step().
    • B. GetByTestId().
    • C. Browser.newContext().
    • D. Test.use().correct

    Why: test.use(): Overrides fixtures/options such as viewport or locale for a test group.

  8. 8. "Opens the HTML report of the last test run" — in Playwright, this describes which of the following?

    • A. Trace: 'on-first-retry'.
    • B. Npx playwright show-report.correct
    • C. Page.screenshot().
    • D. Test.step().

    Why: npx playwright show-report: Opens the HTML report of the last test run.

  9. 9. "Locates elements containing the given text" — in Playwright, this describes which of the following?

    • A. GetByText().correct
    • B. Page.waitForResponse().
    • C. Expect(locator).toBeVisible().
    • D. Page.evaluate().

    Why: getByText(): Locates elements containing the given text.

  10. 10. Which statement correctly describes Playwright?

    • A. GetByRole() is discouraged in favor of XPath as the most resilient locator strategy.
    • B. Playwright cannot send API requests without opening a browser page.
    • C. Visual screenshot comparison requires a third-party plugin in Playwright.
    • D. Expect(page).toHaveScreenshot() performs visual comparison against a stored baseline image.correct

    Why: Built-in screenshot assertions enable visual regression testing.

  11. 11. Which of the following statements about Playwright is TRUE?

    • A. Playwright cannot send API requests without opening a browser page.
    • B. Playwright's auto-waiting performs actionability checks (visible, stable, enabled) before interacting with an element.correct
    • C. Page.route() can observe requests but can never modify or block them.
    • D. Playwright tests always run sequentially unless you buy a parallelization license.

    Why: Actions wait for elements to be actionable, reducing flakiness.

  12. 12. Identify the accurate statement about Playwright:

    • A. Playwright's auto-waiting performs actionability checks (visible, stable, enabled) before interacting with an element.correct
    • B. Playwright can only test Chromium-based browsers.
    • C. BrowserContexts share cookies and localStorage with each other by default.
    • D. Playwright assertions evaluate exactly once and fail immediately if the condition is not yet true.

    Why: Actions wait for elements to be actionable, reducing flakiness.

  13. 13. "Clears and types text into an input field" — in Playwright, this describes which of the following?

    • A. Locator.fill().correct
    • B. Test.use().
    • C. Npx playwright show-report.
    • D. FullyParallel.

    Why: locator.fill(): Clears and types text into an input field.

  14. 14. In Playwright, which of the following is described as: "Groups actions into a named step shown in reports and traces"?

    • A. Locator.click().
    • B. Page.screenshot().
    • C. Page.waitForResponse().
    • D. Test.step().correct

    Why: test.step(): Groups actions into a named step shown in reports and traces.

  15. 15. In Playwright, which of the following is described as: "Waits for a network response matching a URL or predicate"?

    • A. Page.waitForResponse().correct
    • B. Locator.fill().
    • C. Projects.
    • D. FullyParallel.

    Why: page.waitForResponse(): Waits for a network response matching a URL or predicate.

  16. 16. Which Playwright concept matches this description: "Config option that records a trace only when a test is retried"?

    • A. Trace: 'on-first-retry'.correct
    • B. Page.evaluate().
    • C. GetByText().
    • D. Page.screenshot().

    Why: trace: 'on-first-retry': Config option that records a trace only when a test is retried.

  17. 17. In Playwright, which of the following is described as: "Creates a fresh isolated browser session"?

    • A. FullyParallel.
    • B. Test.use().
    • C. Locator.fill().
    • D. Browser.newContext().correct

    Why: browser.newContext(): Creates a fresh isolated browser session.

  18. 18. Which Playwright concept matches this description: "Groups actions into a named step shown in reports and traces"?

    • A. Test.use().
    • B. Locator.fill().
    • C. Test.step().correct
    • D. Page.goto().

    Why: test.step(): Groups actions into a named step shown in reports and traces.

  19. 19. In Playwright, which of the following is described as: "Locates elements by the data-testid attribute"?

    • A. Test.step().
    • B. Page.goto().
    • C. GetByTestId().correct
    • D. Npx playwright show-report.

    Why: getByTestId(): Locates elements by the data-testid attribute.

  20. 20. In the context of Playwright, which of the following is a correct statement?

    • A. BrowserContexts share cookies and localStorage with each other by default.
    • B. Playwright fixtures can only be defined globally and cannot be overridden per test.
    • C. Test.describe.configure({ mode: 'serial' }) forces tests in a group to run one after another.correct
    • D. Playwright requires a separate driver binary (like ChromeDriver) for each browser.

    Why: Serial mode is used when tests depend on shared, ordered state.

Related Automation Testing topics