SoftwareTestPilot
25 Q&A

Playwright API Testing Interview Questions and Answers (25 with Code)

25 Playwright API testing interview questions with answers and TypeScript code: the request fixture, APIRequestContext, auth tokens, schema checks, mocking with page.route(), hybrid UI + API tests and CI.

  • 9 min read
  • Difficulty: Mixed (Easy → Hard)
  • Freshers → Experienced
  • Updated October 16, 2026
  • SoftwareTestPilot
SoftwareTestPilot
QA Editorial Team
Published:
0 / 25 reviewed
0%

1. Playwright API Testing Basics

Medium Very Common 1 minQ1 / 25

Q1.Can Playwright be used for API testing? How?

Asked byAirbnbShopifyUberStripe
Why interviewers ask this

This Playwright question checks whether you can go beyond textbook knowledge on Can Playwright be used for API testing? How and reason about it the way a working QA engineer does — with a definition, an example, and the edge case that usually comes up next.

Detailed explanation

Answer: Yes. Playwright Test provides a built-in request fixture, which is an APIRequestContext. It sends HTTP requests directly from Node.js without launching a browser, so API tests are fast. It supports get, post, put, patch, delete, head and a generic fetch.

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

test('GET a user returns 200 and the right id', async ({ request }) => {
  const response = await request.get('/api/users/1');
  expect(response.status()).toBe(200);
  const body = await response.json();
  expect(body.id).toBe(1);
});
Tips to remember
  • Anchor the answer in a real Playwright project — panels reward specificity on Can Playwright be used for API testing? How over textbook wording.
  • Be ready to whiteboard the Can Playwright be used for API testing? How snippet live — panels often ask you to type it, not describe it.
  • Explain setup/teardown ordering and what runs per-test vs per-suite; ordering mistakes are the follow-up question.
RelatedQ3
Medium Very Common 1 minQ2 / 25

Q2.What is APIRequestContext?

Asked byGoogleAirbnbShopifyUber
Why interviewers ask this

Interviewers open with "APIRequestContext" to confirm you can define the concept in one crisp line before going deeper. In Playwright rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation

Answer: It is the Playwright class that sends HTTP requests and stores cookies for those requests. You get one three ways: the request fixture in a test, playwright.request.newContext() for a standalone context with its own settings, or page.request / context.request, which shares cookies with that browser context. That last option matters: if you log in through the API with page.request, the browser page is logged in too.

Tips to remember
  • Open with a one-sentence definition of APIRequestContext, then a concrete Playwright example — never start with history or theory.
  • Be ready to whiteboard the APIRequestContext snippet live — panels often ask you to type it, not describe it.
  • Explain setup/teardown ordering and what runs per-test vs per-suite; ordering mistakes are the follow-up question.
Medium Very Common 1 minQ3 / 25

Q3.Why test APIs with Playwright instead of Postman or REST Assured?

Asked byUberStripeMicrosoftAdobe
Why interviewers ask this

"Why" questions on test APIs with Playwright instead of Postman or REST Assured probe your reasoning, not your memory. Strong candidates connect the choice to a business or reliability outcome — flaky tests, slower feedback loop, or missed defects — instead of parroting a rule.

Detailed explanation

Answer: The main advantage is one framework and one language for UI and API tests: shared fixtures, config, reporting, traces and CI setup. You can also mix API and UI steps in the same test. Postman is still great for exploratory checks and REST Assured fits Java teams well, so the honest answer is "it depends on the team's stack". If a team is moving collections across, our Postman to Playwright migration guide covers the steps.

Tips to remember
  • Tie the "why" for test APIs with Playwright instead of Postman or REST Assured back to a measurable outcome — flake rate, execution time, defect leakage — instead of an opinion.
  • Keep the answer to 60–90 seconds; anything longer signals you can't summarise test APIs with Playwright instead of Postman or REST Assured cleanly.
  • Assert status, schema and business payload — naming all three signals you test contracts, not just happy paths.
Medium Very Common 1 minQ4 / 25

Q4.How do you set a base URL and common headers for all API tests?

Asked byShopifyUberStripeMicrosoft
Why interviewers ask this

Hands-on "how would you set a base URL and common headers for all API tests" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: In playwright.config.ts under use. Then tests call relative paths, and switching environments only needs an environment variable.

// playwright.config.ts
import { defineConfig } from '@playwright/test';

export default defineConfig({
  use: {
    baseURL: process.env.API_BASE_URL ?? 'https://staging.example.com',
    extraHTTPHeaders: {
      Accept: 'application/json',
      Authorization: `Bearer ${process.env.API_TOKEN}`,
    },
  },
});
Tips to remember
  • Walk through set a base URL and common headers for all API tests as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the set a base URL and common headers for all API tests snippet live — panels often ask you to type it, not describe it.
  • Cover token expiry and refresh in your answer; most candidates only describe the happy-path login.
Medium Very Common 1 minQ5 / 25

Q5.How do you send a POST request with a JSON body, query parameters or form data?

Asked byMicrosoftAdobeNetflixGoogle
Why interviewers ask this

Hands-on "how would you send a POST request with a JSON body, query parameters or form data" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: Pass options to the method. data sends JSON (an object is serialised automatically and the content-type is set), params adds query parameters, form sends URL-encoded form fields and multipart sends files.

// JSON body
const created = await request.post('/api/users', {
  data: { name: 'Asha', role: 'qa' },
});

// Query parameters: /api/users?page=2&limit=10
const list = await request.get('/api/users', { params: { page: 2, limit: 10 } });

// URL-encoded form
await request.post('/login', { form: { username: 'qa', password: 'secret' } });
Tips to remember
  • Walk through send a POST request with a JSON body, query parameters or form data as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the send a POST request with a JSON body, query parameters or form data snippet live — panels often ask you to type it, not describe it.
  • Say how you clean up or roll back the data you touch — DB questions are really data-hygiene questions.
Confidence check

If you can confidently answer the Playwright API Testing Basics questions above, you're well prepared for this section of your interview. Move on, or rehearse the trickier ones aloud with our AI mock interviewer.

2. Assertions and Response Validation

Medium Very Common 1 minQ6 / 25

Q6.What does expect(response).toBeOK() check?

Asked byStripeMicrosoftAdobeNetflix
Why interviewers ask this

This Playwright question checks whether you can go beyond textbook knowledge on What does expect(response).toBeOK() check and reason about it the way a working QA engineer does — with a definition, an example, and the edge case that usually comes up next.

Detailed explanation

Answer: It passes when the status is in the 200–299 range. On failure, Playwright prints the response details, which makes the error easier to read than a plain expect(response.status()).toBe(200). I still check the exact status when it matters, for example 201 after a create.

const response = await request.post('/api/orders', { data: { sku: 'BK-101', qty: 1 } });
await expect(response).toBeOK();
expect(response.status()).toBe(201);
Tips to remember
  • Anchor the answer in a real Playwright project — panels reward specificity on What does expect(response).toBeOK() check over textbook wording.
  • Be ready to whiteboard the What does expect(response).toBeOK() check snippet live — panels often ask you to type it, not describe it.
  • Mention auto-waiting, user-facing locators, or trace viewer — one of those three usually earns a follow-up.
Medium Very Common 1 minQ7 / 25

Q7.Is checking the status code enough?

Asked byNetflixGoogleAirbnbShopify
Why interviewers ask this

This Playwright question checks whether you can go beyond textbook knowledge on Is checking the status code enough and reason about it the way a working QA engineer does — with a definition, an example, and the edge case that usually comes up next.

Detailed explanation

Answer: No. A broken endpoint can return 200 with an empty list, wrong fields or an error message inside the body. I check the status, important headers such as content-type, the body fields the consumer depends on, and response time when there is an agreed limit.

const response = await request.get('/api/products/42');
expect(response.status()).toBe(200);
expect(response.headers()['content-type']).toContain('application/json');

const product = await response.json();
expect(product).toMatchObject({ id: 42, currency: 'INR' });
expect(product.price).toBeGreaterThan(0);
Tips to remember
  • Anchor the answer in a real Playwright project — panels reward specificity on Is checking the status code enough over textbook wording.
  • Be ready to whiteboard the Is checking the status code enough snippet live — panels often ask you to type it, not describe it.
  • Assert status, schema and business payload — naming all three signals you test contracts, not just happy paths.
Medium Very Common 1 minQ8 / 25

Q8.How do you validate a response against a JSON schema?

Asked byAdobeNetflixGoogleAirbnb
Why interviewers ask this

Hands-on "how would you validate a response against a JSON schema" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: Playwright has no built-in schema validator, so I use a library such as Ajv (JSON Schema) or Zod. I keep schemas in one folder so contract changes are updated in one place.

import Ajv from 'ajv';
const ajv = new Ajv();

const userSchema = {
  type: 'object',
  required: ['id', 'email'],
  properties: { id: { type: 'number' }, email: { type: 'string' } },
};

test('user matches schema', async ({ request }) => {
  const body = await (await request.get('/api/users/1')).json();
  const validate = ajv.compile(userSchema);
  expect(validate(body), JSON.stringify(validate.errors)).toBe(true);
});
Tips to remember
  • Walk through validate a response against a JSON schema as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the validate a response against a JSON schema snippet live — panels often ask you to type it, not describe it.
  • Tie contract checks to the consumer/provider workflow and where the contract is stored — that's the senior detail panels wait for.
Hard Very Common 1 minQ9 / 25

Q9.How do you test negative cases such as 400, 401 and 404?

Asked byAirbnbShopifyUberStripe
Why interviewers ask this

Hands-on "how would you test negative cases such as 400, 401 and 404" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: Send invalid or unauthorised requests and assert both the status and the error body. By default the request methods do not throw on 4xx/5xx; they return the response. (You can pass failOnStatusCode: true if you want them to throw.)

test('missing required field returns 400 with a message', async ({ request }) => {
  const response = await request.post('/api/users', { data: { name: '' } });
  expect(response.status()).toBe(400);
  const error = await response.json();
  expect(error.message).toContain('name');
});

test('no token returns 401', async ({ playwright }) => {
  const anon = await playwright.request.newContext({ baseURL: process.env.API_BASE_URL });
  const response = await anon.get('/api/me');
  expect(response.status()).toBe(401);
  await anon.dispose();
});
Tips to remember
  • Walk through test negative cases such as 400, 401 and 404 as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the test negative cases such as 400, 401 and 404 snippet live — panels often ask you to type it, not describe it.
  • Cover token expiry and refresh in your answer; most candidates only describe the happy-path login.
Medium Common 1 minQ10 / 25

Q10.How do you check an array in the response, for example that every item has a status of "active"?

Asked byGoogleAirbnbShopifyUber
Why interviewers ask this

Hands-on "how would you check an array in the response, for example that every item has a status of "active"" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: Parse the body and assert on the array, including the empty case, because every() on an empty array is always true.

const users = await (await request.get('/api/users', { params: { status: 'active' } })).json();
expect(users.length).toBeGreaterThan(0);
expect(users.every((u: { status: string }) => u.status === 'active')).toBe(true);
Tips to remember
  • Walk through check an array in the response, for example that every item has a status of "active" as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the check an array in the response, for example that every item has a status of "active" snippet live — panels often ask you to type it, not describe it.
  • Mention auto-waiting, user-facing locators, or trace viewer — one of those three usually earns a follow-up.
Confidence check

If you can confidently answer the Assertions and Response Validation questions above, you're well prepared for this section of your interview. Move on, or rehearse the trickier ones aloud with our AI mock interviewer.

3. Authentication and Test Data

Hard Common 1 minQ11 / 25

Q11.How do you handle bearer token authentication?

Asked byUberStripeMicrosoftAdobe
Why interviewers ask this

Hands-on "how would you handle bearer token authentication" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: Get the token once, then create a context that sends it on every request. I keep credentials in environment variables or a CI secret store, never in the repository.

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

export const test = base.extend<{ api: APIRequestContext }>({
  api: async ({ playwright }, use) => {
    const auth = await playwright.request.newContext({ baseURL: process.env.API_BASE_URL });
    const res = await auth.post('/api/auth/login', {
      data: { email: process.env.TEST_USER, password: process.env.TEST_PASS },
    });
    const { token } = await res.json();
    await auth.dispose();

    const api = await playwright.request.newContext({
      baseURL: process.env.API_BASE_URL,
      extraHTTPHeaders: { Authorization: `Bearer ${token}` },
    });
    await use(api);
    await api.dispose();
  },
});
Tips to remember
  • Walk through handle bearer token authentication as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the handle bearer token authentication snippet live — panels often ask you to type it, not describe it.
  • Cover token expiry and refresh in your answer; most candidates only describe the happy-path login.
Hard Common 1 minQ12 / 25

Q12.How do you log in through the API and then run a UI test as that user?

Asked byShopifyUberStripeMicrosoft
Why interviewers ask this

Hands-on "how would you log in through the API and then run a UI test as that user" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: Use page.request (shares cookies with the page) or save the API session with storageState() and load it into the browser. This skips the slow UI login.

test('dashboard shows the user name', async ({ page }) => {
  await page.request.post('/api/auth/login', {
    form: { email: process.env.TEST_USER!, password: process.env.TEST_PASS! },
  });
  await page.goto('/dashboard'); // already signed in via the shared cookie
  await expect(page.getByRole('heading', { name: /welcome/i })).toBeVisible();
});

// Or save it for every test in a setup project:
// await request.storageState({ path: 'playwright/.auth/user.json' });
Tips to remember
  • Walk through log in through the API and then run a UI test as that user as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the log in through the API and then run a UI test as that user snippet live — panels often ask you to type it, not describe it.
  • Explain setup/teardown ordering and what runs per-test vs per-suite; ordering mistakes are the follow-up question.
Medium Common 1 minQ13 / 25

Q13.How do you create test data through the API and clean it up?

Asked byMicrosoftAdobeNetflixGoogle
Why interviewers ask this

Hands-on "how would you create test data through the API and clean it up" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: Create data in a fixture before the test and delete it after use(), so cleanup runs even when the test fails. Each test gets unique data, which keeps parallel workers from colliding.

export const test = base.extend<{ order: { id: string } }>({
  order: async ({ request }, use) => {
    const res = await request.post('/api/orders', {
      data: { sku: 'BK-101', ref: `test-${Date.now()}-${Math.random()}` },
    });
    const order = await res.json();
    await use(order);
    await request.delete(`/api/orders/${order.id}`);
  },
});
Tips to remember
  • Walk through create test data through the API and clean it up as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the create test data through the API and clean it up snippet live — panels often ask you to type it, not describe it.
  • Call out test isolation and shared-state risk (data, sessions, ports) before you talk about worker counts.
Medium Common 1 minQ14 / 25

Q14.How do you chain requests, using the id from one response in the next?

Asked byStripeMicrosoftAdobeNetflix
Why interviewers ask this

Hands-on "how would you chain requests, using the id from one response in the next" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: Read the value from the first response and pass it to the next call. I assert each step so a failure points to the right request.

test('create, update and read back a user', async ({ request }) => {
  const created = await request.post('/api/users', { data: { name: 'Ravi' } });
  await expect(created).toBeOK();
  const { id } = await created.json();

  const updated = await request.patch(`/api/users/${id}`, { data: { name: 'Ravi K' } });
  await expect(updated).toBeOK();

  const read = await (await request.get(`/api/users/${id}`)).json();
  expect(read.name).toBe('Ravi K');
});
Tips to remember
  • Walk through chain requests, using the id from one response in the next as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the chain requests, using the id from one response in the next snippet live — panels often ask you to type it, not describe it.
  • Mention auto-waiting, user-facing locators, or trace viewer — one of those three usually earns a follow-up.
Medium Common 1 minQ15 / 25

Q15.How do you upload a file through an API?

Asked byNetflixGoogleAirbnbShopify
Why interviewers ask this

Hands-on "how would you upload a file through an API" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: Use the multipart option with a buffer or stream and a filename.

import fs from 'fs';

const response = await request.post('/api/documents', {
  multipart: {
    title: 'Test plan',
    file: { name: 'plan.pdf', mimeType: 'application/pdf', buffer: fs.readFileSync('fixtures/plan.pdf') },
  },
});
await expect(response).toBeOK();
Tips to remember
  • Walk through upload a file through an API as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the upload a file through an API snippet live — panels often ask you to type it, not describe it.
  • Explain setup/teardown ordering and what runs per-test vs per-suite; ordering mistakes are the follow-up question.
Confidence check

If you can confidently answer the Authentication and Test Data questions above, you're well prepared for this section of your interview. Move on, or rehearse the trickier ones aloud with our AI mock interviewer.

4. Mocking, Intercepting and Hybrid Tests

Medium Common 1 minQ16 / 25

Q16.What is the difference between the request fixture and page.route()?

Asked byAdobeNetflixGoogleAirbnb
Why interviewers ask this

Interviewers open with "difference between the request fixture and page.route()" to confirm you can define the concept in one crisp line before going deeper. In Playwright rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation

Answer: The request fixture sends real HTTP calls from the test to test an API. page.route() intercepts calls the browser page makes, so you can mock, change or block them while testing the UI. Routes set on a page do not affect the request fixture.

Tips to remember
  • Open with a one-sentence definition of difference between the request fixture and page.route(), then a concrete Playwright example — never start with history or theory.
  • Be ready to whiteboard the difference between the request fixture and page.route() snippet live — panels often ask you to type it, not describe it.
  • Say when you'd mock versus hit the real dependency; unconditional mocking is a red flag for integration coverage.
Hard Common 1 minQ17 / 25

Q17.How do you mock an API response for a UI test?

Asked byAirbnbShopifyUberStripe
Why interviewers ask this

Hands-on "how would you mock an API response for a UI test" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: Register a route before the page makes the call and fulfil it with test data. This is useful for empty states, errors and slow or unstable third-party services.

test('shows empty state when there are no orders', async ({ page }) => {
  await page.route('**/api/orders', (route) =>
    route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify([]) })
  );
  await page.goto('/orders');
  await expect(page.getByText('You have no orders yet')).toBeVisible();
});

test('shows an error banner on 500', async ({ page }) => {
  await page.route('**/api/orders', (route) => route.fulfill({ status: 500 }));
  await page.goto('/orders');
  await expect(page.getByRole('alert')).toContainText('Something went wrong');
});
Tips to remember
  • Walk through mock an API response for a UI test as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the mock an API response for a UI test snippet live — panels often ask you to type it, not describe it.
  • Say when you'd mock versus hit the real dependency; unconditional mocking is a red flag for integration coverage.
Medium Common 1 minQ18 / 25

Q18.How do you change part of a real response instead of mocking all of it?

Asked byGoogleAirbnbShopifyUber
Why interviewers ask this

Hands-on "how would you change part of a real response instead of mocking all of it" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: Call route.fetch() to get the real response, edit the JSON, then fulfil with the edited body. This keeps the rest of the data realistic.

await page.route('**/api/profile', async (route) => {
  const response = await route.fetch();
  const json = await response.json();
  json.plan = 'premium';
  await route.fulfill({ response, json });
});
Tips to remember
  • Walk through change part of a real response instead of mocking all of it as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the change part of a real response instead of mocking all of it snippet live — panels often ask you to type it, not describe it.
  • Say when you'd mock versus hit the real dependency; unconditional mocking is a red flag for integration coverage.
Medium Occasional 1 minQ19 / 25

Q19.How do you check that clicking a button sends the right API request?

Asked byUberStripeMicrosoftAdobe
Why interviewers ask this

Hands-on "how would you check that clicking a button sends the right API request" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: Start waiting for the request or response before the click, then assert on it.

const requestPromise = page.waitForRequest(
  (req) => req.url().includes('/api/cart') && req.method() === 'POST'
);
await page.getByRole('button', { name: 'Add to cart' }).click();
const req = await requestPromise;
expect(req.postDataJSON()).toMatchObject({ sku: 'BK-101', qty: 1 });
Tips to remember
  • Walk through check that clicking a button sends the right API request as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the check that clicking a button sends the right API request snippet live — panels often ask you to type it, not describe it.
  • Mention auto-waiting, user-facing locators, or trace viewer — one of those three usually earns a follow-up.
Hard Occasional 1 minQ20 / 25

Q20.What is a hybrid UI + API test, and why use one?

Asked byShopifyUberStripeMicrosoft
Why interviewers ask this

Interviewers open with "hybrid UI + API test, and why use one" to confirm you can define the concept in one crisp line before going deeper. In Playwright rounds this filters out candidates who only remember syntax and can't articulate the underlying idea to a non-expert teammate.

Detailed explanation

Answer: It uses the API for setup and verification and the UI only for the behaviour under test. For example: create a product by API, edit its price in the UI, then read it back by API to confirm the change was saved. It is faster and less flaky than doing every step in the browser, and it proves the UI change actually reached the backend.

test('price edit is saved', async ({ page, request }) => {
  const { id } = await (await request.post('/api/products', { data: { name: 'Mug', price: 299 } })).json();

  await page.goto(`/admin/products/${id}`);
  await page.getByLabel('Price').fill('349');
  await page.getByRole('button', { name: 'Save' }).click();
  await expect(page.getByText('Saved')).toBeVisible();

  const saved = await (await request.get(`/api/products/${id}`)).json();
  expect(saved.price).toBe(349);
});
Tips to remember
  • Open with a one-sentence definition of hybrid UI + API test, and why use one, then a concrete Playwright example — never start with history or theory.
  • Be ready to whiteboard the hybrid UI + API test, and why use one snippet live — panels often ask you to type it, not describe it.
  • Quote a real flake-rate number before and after your fix; measured outcomes score far higher than "we added retries".
Confidence check

If you can confidently answer the Mocking, Intercepting and Hybrid Tests questions above, you're well prepared for this section of your interview. Move on, or rehearse the trickier ones aloud with our AI mock interviewer.

5. Framework Design and CI

Hard Occasional 1 minQ21 / 25

Q21.How would you structure a Playwright API test framework?

Asked byMicrosoftAdobeNetflixGoogle
Why interviewers ask this

Hands-on "how would you structure a Playwright API test framework" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: A simple, scalable layout:

  • Config — baseURL and headers from environment variables, one project per environment if needed.
  • Fixtures — authenticated contexts and test data with cleanup.
  • API clients — small classes or functions per resource (for example UsersApi.create()) so tests read like intent, not URLs.
  • Schemas — JSON schemas or Zod types in one folder.
  • Tests — grouped by resource, tagged (for example @smoke) for selective runs.
export class UsersApi {
  constructor(private request: APIRequestContext) {}
  create(data: { name: string }) { return this.request.post('/api/users', { data }); }
  get(id: number) { return this.request.get(`/api/users/${id}`); }
}
Tips to remember
  • Walk through structure a Playwright API test framework as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the structure a Playwright API test framework snippet live — panels often ask you to type it, not describe it.
  • Tie contract checks to the consumer/provider workflow and where the contract is stored — that's the senior detail panels wait for.
Medium Occasional 1 minQ22 / 25

Q22.How do you run API tests without starting a browser?

Asked byStripeMicrosoftAdobeNetflix
Why interviewers ask this

Hands-on "how would you run API tests without starting a browser" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: Tests that use only the request fixture never launch a browser. I put them in a separate project (for example testDir: './tests/api') so CI can run them first as a fast gate, before the slower browser projects.

projects: [
  { name: 'api', testDir: './tests/api' },
  { name: 'chromium', testDir: './tests/ui', use: { ...devices['Desktop Chrome'] }, dependencies: ['api'] },
]
Tips to remember
  • Walk through run API tests without starting a browser as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the run API tests without starting a browser snippet live — panels often ask you to type it, not describe it.
  • Explain setup/teardown ordering and what runs per-test vs per-suite; ordering mistakes are the follow-up question.
Medium Occasional 1 minQ23 / 25

Q23.How do you debug a failing API test?

Asked byNetflixGoogleAirbnbShopify
Why interviewers ask this

Hands-on "how would you debug a failing API test" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: Turn on traces (trace: 'on-first-retry'); API calls made through Playwright appear in the trace viewer with request and response details. I also attach the response body to the failure message, for example expect(response, await response.text()).toBeOK(), so CI logs show what the server returned.

Tips to remember
  • Walk through debug a failing API test as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the debug a failing API test snippet live — panels often ask you to type it, not describe it.
  • Say who reads the report and what decision it drives — evidence-for-humans framing beats a tool name list.
Medium Occasional 1 minQ24 / 25

Q24.How do you test GraphQL with Playwright?

Asked byAdobeNetflixGoogleAirbnb
Why interviewers ask this

Hands-on "how would you test GraphQL with Playwright" questions reveal whether you've actually shipped Playwright code or only read about it. Interviewers listen for concrete steps, the tools you'd reach for first, and the failure mode you'd guard against.

Detailed explanation

Answer: GraphQL is usually a POST to one endpoint with a query and variables. Remember that GraphQL often returns 200 even when there are errors, so always check the errors field.

const res = await request.post('/graphql', {
  data: { query: 'query($id: ID!) { user(id: $id) { id name } }', variables: { id: '1' } },
});
const body = await res.json();
expect(body.errors).toBeUndefined();
expect(body.data.user.id).toBe('1');

For more depth, read our GraphQL API testing guide.

Tips to remember
  • Walk through test GraphQL with Playwright as numbered steps and call out the tool, command, or API used at each step.
  • Be ready to whiteboard the test GraphQL with Playwright snippet live — panels often ask you to type it, not describe it.
  • Say how you clean up or roll back the data you touch — DB questions are really data-hygiene questions.
Easy Occasional 1 minQ25 / 25

Q25.Can Playwright replace dedicated performance or contract testing tools?

Asked byAirbnbShopifyUberStripe
Why interviewers ask this

This Playwright question checks whether you can go beyond textbook knowledge on Can Playwright replace dedicated performance or contract testing tools and reason about it the way a working QA engineer does — with a definition, an example, and the edge case that usually comes up next.

Detailed explanation

Answer: No. Playwright can check that a single response arrives within a limit, but it is not a load testing tool; use JMeter, k6 or similar for load. For consumer-driven contract testing, tools such as Pact are built for that job. Playwright API tests sit best in the functional layer: correctness, auth, error handling and end-to-end data flow.

Tips to remember
  • Anchor the answer in a real Playwright project — panels reward specificity on Can Playwright replace dedicated performance or contract testing tools over textbook wording.
  • Keep the answer to 60–90 seconds; anything longer signals you can't summarise Can Playwright replace dedicated performance or contract testing tools cleanly.
  • Tie contract checks to the consumer/provider workflow and where the contract is stored — that's the senior detail panels wait for.
RelatedQ23
Confidence check

If you can confidently answer the Framework Design and CI questions above, you're well prepared for this section of your interview. Move on, or rehearse the trickier ones aloud with our AI mock interviewer.

Quick revision

  1. Q1: Can Playwright be used for API testing? How — Answer: Yes.
  2. Q2: What is APIRequestContext — Answer: It is the Playwright class that sends HTTP requests and stores cookies for those requests.
  3. Q3: Why test APIs with Playwright instead of Postman or REST Assured — Answer: The main advantage is one framework and one language for UI and API tests: shared fixtures, config, reporting, traces and CI setup.
  4. Q4: How do you set a base URL and common headers for all API tests — Answer: In playwright.config.ts under use .
  5. Q5: How do you send a POST request with a JSON body, query parameters or form data — Answer: Pass options to the method.

Frequently asked questions

1.Can Playwright do API testing without a browser?
Yes. The request fixture (APIRequestContext) sends HTTP requests directly from Node.js, so tests that use only it never launch a browser and run quickly.
2.What is the request fixture in Playwright?
It is a built-in Playwright Test fixture that gives each test an APIRequestContext. It respects baseURL and extraHTTPHeaders from your config and supports get, post, put, patch, delete, head and fetch.
3.Does page.route() mock requests made by the request fixture?
No. page.route() only intercepts network traffic from the browser page. Calls made with the request fixture go straight to the server.
4.How do I validate a JSON schema in Playwright?
Playwright has no built-in schema validator. Use a library such as Ajv or Zod to validate the parsed response body, and assert that validation passed.
5.Is Playwright better than Postman for API testing?
Neither is better in every case. Playwright suits teams that want UI and API tests in one code framework; Postman is strong for exploring APIs and sharing collections.
6.Which Playwright API testing topics come up most in interviews?
The request fixture and APIRequestContext, assertions beyond status codes, bearer token auth, test data setup and cleanup, mocking with page.route(), hybrid UI + API tests and running API tests in CI.

Playwright automation jobs hiring now

Live, indexable Playwright openings — updated daily in Jobs Radar.

Browse all QA jobs on Jobs Radar

Loading current openings…

Home

References

  1. 1
    Playwright: API testing— playwright.dev
  2. 2
  3. 3
  4. 4
    Playwright: Mock APIs— playwright.dev
  5. 5
    Playwright: Authentication— playwright.dev

Discussion

Ask a question, share your experience, or correct us. Be kind — real people are reading.