Playwright Interview Questions and Answers (2026): 25 Q&A with Code for QA and SDET Roles

Create your free QA Jobs accountDaily verified QA jobs · 10-second signup · No card needed

Short answer: Playwright interviews in 2026 test five things – locators, auto-waiting and web-first assertions, test isolation with browser contexts and fixtures, debugging with traces, and running suites in parallel in CI. If you can explain each with a small code example and one real debugging story, you are ready for most QA automation and SDET rounds.

Playwright is an open-source end-to-end testing framework from Microsoft that drives Chromium, Firefox and WebKit with one API, and supports TypeScript/JavaScript, Python, Java and .NET (official docs). Below are 25 questions we see in Indian QA and SDET interviews, grouped by topic, with short answers you can say out loud and code in TypeScript (the most common choice in job posts).

Playwright basics (Q1–Q5)

1. What is Playwright and why do teams choose it over Selenium?

Playwright is a browser automation and testing framework that controls Chromium, Firefox and WebKit through one API. Teams pick it for built-in auto-waiting (fewer flaky tests), web-first assertions that retry, isolated browser contexts per test, a built-in test runner with parallel workers, and tools like Trace Viewer and Codegen. Selenium is still widely used, has the biggest ecosystem and supports more languages and grids – a good answer says “it depends on the project”, not “Selenium is dead”.

2. Explain Browser, BrowserContext and Page.

Browser is one launched browser process. A BrowserContext is an isolated, incognito-like session inside it with its own cookies and storage – cheap to create, so each test gets a fresh one. A Page is a single tab inside a context. Two contexts in one browser can simulate two different users (e.g. buyer and seller) in the same test.

3. Which browsers and languages does Playwright support?

Chromium (Chrome, Edge), Firefox and WebKit (the engine behind Safari), on Windows, macOS and Linux, headed or headless. Languages: TypeScript/JavaScript, Python, Java and C#/.NET. The built-in test runner (@playwright/test) is for JS/TS; other languages usually pair Playwright with pytest, JUnit/TestNG or NUnit.

4. What does playwright.config.ts usually contain?

testDir, timeout, retries, workers, reporter, a shared use block (baseURL, trace, screenshot, video) and projects – one per browser or device.

import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  testDir: './tests',
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 4 : undefined,
  reporter: [['html'], ['list']],
  use: {
    baseURL: 'https://staging.example.com',
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
  },
  projects: [
    { name: 'chromium', use: { ...devices['Desktop Chrome'] } },
    { name: 'webkit',   use: { ...devices['iPhone 13'] } },
  ],
});

5. Write a simple login test.

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

test('valid user can log in', async ({ page }) => {
  await page.goto('/login');
  await page.getByLabel('Email').fill('tester@example.com');
  await page.getByLabel('Password').fill(process.env.TEST_PASSWORD!);
  await page.getByRole('button', { name: 'Sign in' }).click();
  await expect(page).toHaveURL(/dashboard/);
  await expect(page.getByRole('heading', { name: 'Welcome' })).toBeVisible();
});

Interviewers look for: user-facing locators, no hard-coded password, no waitForTimeout, and an assertion on the result – not just clicks.

Locators, waits and assertions (Q6–Q11)

6. Which locators do you prefer, and why?

User-facing locators first: getByRole, getByLabel, getByPlaceholder, getByText, then getByTestId for elements with no accessible name. They survive CSS refactors and match how a user finds the element. CSS/XPath are the last option. Playwright’s own docs recommend this order (Locators guide).

7. What is auto-waiting?

Before an action like click(), Playwright waits until the element is attached, visible, stable (not animating), enabled and able to receive events. So you rarely need explicit waits. If the checks don’t pass within the timeout, the action fails with a clear message.

8. What are web-first assertions?

Assertions like await expect(locator).toBeVisible() or toHaveText() retry until the condition is true or the timeout ends. Compare: expect(await locator.isVisible()).toBe(true) checks once and is a common source of flakiness. Saying this difference clearly impresses interviewers.

9. How do you handle a list where you need one specific row?

const row = page.getByRole('row').filter({ hasText: 'Order #1042' });
await row.getByRole('button', { name: 'Cancel' }).click();
await expect(row.getByText('Cancelled')).toBeVisible();

Chaining and filter({ hasText }) scope the locator, so you never depend on row index.

10. “Strict mode violation” – what does it mean?

An action locator matched more than one element. Playwright refuses to guess. Fix it by making the locator more specific (role + name, filter, chaining) – use .first() only when “any of them” is truly correct.

11. How do you handle iframes, new tabs and dialogs?

// iframe
await page.frameLocator('#payment').getByLabel('Card number').fill('4111111111111111');

// new tab
const [newPage] = await Promise.all([
  page.context().waitForEvent('page'),
  page.getByRole('link', { name: 'Open invoice' }).click(),
]);
await expect(newPage).toHaveURL(/invoice/);

// JS dialog
page.once('dialog', d => d.accept());
await page.getByRole('button', { name: 'Delete' }).click();

Fixtures, login and test isolation (Q12–Q16)

12. What are fixtures?

Fixtures give each test exactly what it needs (page, context, a logged-in user, test data) and clean up afterwards. Built-ins include page, context, browser and request. You extend them with test.extend, which is cleaner than long beforeEach hooks.

type Fixtures = { loginPage: LoginPage };
export const test = base.extend<Fixtures>({
  loginPage: async ({ page }, use) => {
    const lp = new LoginPage(page);
    await lp.goto();
    await use(lp);
  },
});

13. How do you avoid logging in before every test?

Log in once in a setup project, save the session with storageState, and let other projects reuse it (Authentication docs). Keep the state file out of Git.

// auth.setup.ts
setup('authenticate', async ({ page }) => {
  await page.goto('/login');
  // ...fill and submit...
  await page.context().storageState({ path: 'playwright/.auth/user.json' });
});

// playwright.config.ts → projects
{ name: 'setup', testMatch: /.*\.setup\.ts/ },
{ name: 'chromium', use: { storageState: 'playwright/.auth/user.json' }, dependencies: ['setup'] }

14. How do you structure a framework? Page Object Model or not?

A common answer: page objects that expose locators and user actions (not assertions), fixtures that create them, test data in factories or JSON, environment config in .env, and tests that read like user stories. Mention that you keep page objects thin – a 2,000-line page object is a red flag.

15. How do tests run in parallel, and how do you stop them clashing?

Test files run in parallel across worker processes; tests inside a file run in order unless you set test.describe.configure({ mode: 'parallel' }). Each test gets its own context, so cookies don’t leak. Data clashes are your job: create unique data per test (e.g. an email with a timestamp or worker index) instead of sharing one “test user”.

16. What are projects used for?

Running the same tests with different settings: browsers, mobile devices, environments, or a setup project that other projects depend on. Example: run smoke tests on Chromium for every pull request and the full suite on all three engines nightly.

Network mocking and API testing (Q17–Q19)

17. How do you mock an API response?

await page.route('**/api/orders', route =>
  route.fulfill({ status: 500, json: { error: 'Server down' } })
);
await page.goto('/orders');
await expect(page.getByText('Something went wrong')).toBeVisible();

Use it to test error states, empty states and slow responses that are hard to create on a real backend – but keep some end-to-end tests un-mocked.

18. Can Playwright test APIs without a browser?

test('create user API', async ({ request }) => {
  const res = await request.post('/api/users', { data: { name: 'Asha' } });
  expect(res.status()).toBe(201);
  const body = await res.json();
  expect(body.name).toBe('Asha');
});

A strong pattern: create test data through the API, then verify it in the UI – faster and less flaky than creating everything by clicking. For deeper API rounds, revise our REST Assured API testing questions too.

19. How do you wait for a specific network call?

const responsePromise = page.waitForResponse(r =>
  r.url().includes('/api/search') && r.status() === 200);
await page.getByRole('searchbox').fill('playwright');
const response = await responsePromise;

Start waiting before the action that triggers the call – otherwise you can miss a fast response.

Interviewers often follow Q17–Q19 with plain HTTP questions – 401 vs 403, PUT vs PATCH, idempotency. Revise them in our API testing interview questions with Postman examples before an SDET round.

Debugging, flakiness and CI (Q20–Q25)

20. A test passes locally but fails in CI. How do you debug it?

Turn on traces (trace: 'on-first-retry'), download the trace from the CI run and open it in Trace Viewer: you see every action, DOM snapshots, console logs and network calls. Typical causes: slower CI machines, different screen size, test data shared between parallel workers, time zone or locale, or a missing environment variable. This is the best place to tell your own real debugging story.

21. How do you deal with a flaky test?

Find the cause, don’t hide it: replace one-shot checks with web-first assertions, remove waitForTimeout, wait for the right network response, make test data unique. Retries in CI are a safety net, and the HTML report marks retried passes as “flaky” so they stay visible. Quarantine with test.fixme only with a ticket.

22. What tools help you write and debug tests?

Codegen (npx playwright codegen) records actions and suggests locators; UI mode (npx playwright test --ui) runs tests with a timeline and watch mode; Inspector (--debug or page.pause()) steps through a test; Trace Viewer replays a run after it finished.

23. How do you run Playwright in CI?

# GitHub Actions – key steps
- run: npm ci
- run: npx playwright install --with-deps
- run: npx playwright test --shard=${{ matrix.shard }}/4
- uses: actions/upload-artifact@v4
  if: always()
  with: { name: playwright-report, path: playwright-report/ }

Mention sharding across machines, uploading the HTML report and traces as artifacts, and running a smoke subset on every pull request.

24. How do you do visual testing?

await expect(page).toHaveScreenshot() compares against a stored baseline and fails on pixel differences above a threshold. Generate baselines on the same OS as CI (fonts render differently), mask dynamic areas like dates and ads, and review diffs before updating baselines with --update-snapshots.

25. Scenario: the “Pay” button sometimes double-charges in production. What would you automate?

A test that double-clicks Pay and asserts only one order is created (check via API), a test that slows the payment response with page.route and asserts the button is disabled while waiting, and a test that goes offline mid-payment (context.setOffline(true)) and checks a clear retry message. Scenario questions like this decide senior rounds – answer with risk first, then code.

Playwright jobs posted on QA Jobs India this week

Check each post for the exact tool stack – some list Playwright as “good to have” next to Selenium or Cypress. Fresh automation roles are added to Daily QA Jobs every morning.

A 5-day Playwright interview plan

  1. Day 1: Install Playwright, write 5 tests on a demo app using only getByRole/getByLabel and web-first assertions.
  2. Day 2: Add page objects, a custom fixture and storageState login.
  3. Day 3: Mock one error response with page.route and write 2 API tests with request.
  4. Day 4: Push to GitHub, run in GitHub Actions, open a trace from a failed CI run.
  5. Day 5: Practise Q1–Q25 out loud and prepare one real flaky-test story (cause → fix → result).

Moving from Selenium? Our SDET interview questions and Cypress jobs guide cover the framework-design questions that come up next to Playwright.

FAQ

Is Playwright better than Selenium for getting a job in India?

Both appear in job posts. Selenium with Java is still very common in services companies; Playwright is common in product companies and newer projects. Knowing one well and being able to explain the differences is better than knowing both a little.

Should I learn Playwright with TypeScript, Java or Python?

TypeScript gives you the full built-in test runner and is the most common in Playwright job posts. If your current job uses Java or Python, Playwright works there too – match the language of the roles you are applying for.

Can a manual tester learn Playwright?

Yes. Learn basic JavaScript/TypeScript (variables, functions, async/await) first, then Playwright. The 5-day plan above assumes those basics.

How many Playwright questions are asked in an SDET interview?

It varies, but expect a mix: 5–10 concept questions, one live coding task (often a login or search test), and one scenario or debugging question.

Get Playwright and automation jobs every morning – free. Create a free QA Jobs India account for today’s free jobs with direct HR emails and your free QA Passport profile.

Create free account →

Already a member? Add the Courses pack or Company Interview Kits from Billing to prepare for automation rounds.

SIGN UP ONCE
Once you sign up, you get all this
Sign up now
  • 100+ fresh QA jobs daily + Direct HR email IDsLive every morning at 9 AM — apply straight to HR
  • Weekly Mega Job Fair800+ QA jobs from India & around the world, every week
  • Certified QA coursesUp to 3 courses included · all 17 for ₹500
  • AI ATS Resume BuilderFree resume points included
  • Full LinkedQA feedEvery post, fully unblurred
  • Complete QA Material libraryInterview Q&A, cheat sheets, templates & roadmaps

Instant activation right after payment · One login for jobs, courses, resume & LinkedQA

Explore more · Free · Updated daily

QA Jobs Hub

Every QA job opening, company profile and career guide on QA Jobs India — India & Global, in one place.

Open QA Jobs Hub
✓ You're subscribed — job alerts arrive daily at 9 AM
Scroll to Top