QA Interview Hub · Knowledge base · Quizzes · Українська

All topics

Playwright interview questions

101 questions on Playwright, from the basics to the hard ones. Answers and explanations are in the quiz and the knowledge base.

By level: Junior QA interview questions · Middle QA interview questions · Senior QA interview questions

Architecture and isolation

  1. How does Playwright control the browser? Junior
  2. Which browser engines does Playwright support? Junior
  3. What is the fundamental difference between Playwright and Selenium? Middle
  4. Mobile emulation with devices['iPhone 13']: what is it really? Middle

Take the quiz for this chapter · Read the explanation in the knowledge base

Browser, Context, Page

  1. What is a BrowserContext? Junior
  2. What is the object hierarchy in Playwright? Junior
  3. How do you get the page that opens in a new tab after a click? Middle
    // ?
    await page.getByRole('link', { name: 'Contract' }).click();
    // ?
  4. How do you test a chat between two users in one test? Middle
  5. What does Playwright do with alert and confirm dialogs if you don't handle them? Middle

Take the quiz for this chapter · Read the explanation in the knowledge base

Locators

  1. Which locators does Playwright recommend preferring? Junior
  2. What is a Locator in Playwright? Junior
  3. How does a Locator differ from an ElementHandle? Middle
  4. The page has three “Delete” buttons. What happens? Middle
    await page.getByRole('button', { name: 'Delete' }).click();
  5. How do you click “Delete” in the table row with the product “Thermos”? The product name and the button sit in different cells of that row. Middle
  6. Which attribute does getByTestId look for by default? Middle
  7. How do you work with an element inside an iframe? Middle
  8. Do Playwright CSS locators see elements in the Shadow DOM? Senior
  9. What does the exact: true option do in getByRole('button', { name: 'Save', exact: true })? Junior
  10. How do you find a product card that contains a “Buy” button but no “Out of stock” badge? Middle
  11. What is locator.or() for? Middle
  12. Why is locator.first() risky as the main way around strict mode? Middle
  13. What does await page.getByRole('listitem').all() return right after goto if the list is still loading? Middle
  14. How does getByText('Total') differ from getByText('Total', { exact: true })? Junior
  15. Why is getByRole considered better than CSS even for internal admin panels? Middle
  16. What does toMatchAriaSnapshot() check? Middle

Take the quiz for this chapter · Read the explanation in the knowledge base

Auto-waiting and web-first assertions

  1. What does Playwright check before click() (auto-waiting)? Junior
  2. The text updates a second after the page loads. Which check is reliable? Middle
  3. What happens if you forget await before an assertion? Middle
    expect(page.getByText('Success')).toBeVisible();
  4. How do you reliably check that a list has 10 products that load asynchronously? Middle
  5. Why is page.waitForTimeout(3000) considered an anti-pattern? Middle
  6. How do you wait for a condition that no built-in assertion checks (for example, a status in the database)? Middle
  7. What is expect.soft? Junior
  8. How does toBeAttached() differ from toBeVisible()? Junior
  9. Which assertion best checks that a spinner has disappeared? Junior
  10. How does toHaveText differ from toContainText? Middle
  11. What is await expect(async () => { ... }).toPass() for? Middle
  12. How do you reliably wait for the page change after logging in? Middle
  13. A test checks that there are 0 rows after deleting them. What is more reliable? Middle

Take the quiz for this chapter · Read the explanation in the knowledge base

Interaction: actions, tabs, frames, files, dialogs

  1. How does fill() differ from pressSequentially()? Middle
  2. What does the { force: true } option do in click()? Middle
  3. How do you choose a file for an <input type="file">? Junior

Take the quiz for this chapter · Read the explanation in the knowledge base

Fixtures and test structure

  1. What are fixtures in @playwright/test? Junior
  2. What does the line await use(...) do in a fixture? Middle
    export const test = base.extend<{ loginPage: LoginPage }>({
      loginPage: async ({ page }, use) => {
        const lp = new LoginPage(page);
        await lp.open();
        await use(lp);
        await lp.logout();
      },
    });
  3. When does a fixture run that neither the test, nor its hooks, nor other fixtures in use request? Middle
  4. How does a scope: 'worker' fixture differ from a 'test' one? Middle
  5. Why are fixtures often better than beforeEach? Middle
  6. Why use test.step() in a test? Middle
  7. How do you tag a test and run only smoke tests? Middle
  8. What happens to the tests in a file with test.describe.configure({ mode: 'serial' }) if the second test fails? Middle
  9. Why is a setup project with dependencies better than globalSetup? Senior

Take the quiz for this chapter · Read the explanation in the knowledge base

Network: route and mocks

  1. What is page.route() for? Junior
  2. How do you replace an API response with a 500 error? Middle
  3. How do you change one field in a real server response? Middle
  4. How do you wait for a specific response after a click and check it? Middle
  5. How do you wait for a request to be sent and check its body? Middle
  6. How do you add an authorization header to every API request the page itself makes, without changing the app code? Middle
  7. How do you speed up a test by blocking images and third-party analytics without touching the other requests? Middle

Take the quiz for this chapter · Read the explanation in the knowledge base

API testing in Playwright

  1. What is the request fixture? Junior
  2. Does page.route() intercept requests sent with the request fixture? Middle
  3. What is wrong with this code and how do you fix it? Middle
    import { request, test, expect } from '@playwright/test';
    
    test('creates an account', async () => {
      const api = await request.newContext({ baseURL: 'https://api.test.bank' });
      const res = await api.post('/accounts', { data: { currency: 'UAH' } });
      expect(res.ok()).toBeTruthy();
    });
  4. The test logged in through the UI. Does the same session go into page.request.get() and into the request fixture? Middle
  5. A test creates an account through the API and checks it in the UI. Tests run in parallel in several workers. How do you keep them independent? Senior
  6. How do you pass the query parameters isbn=1234 and page=2 in a GET request through the request fixture? Junior
  7. The server accepts the login as an HTML form (application/x-www-form-urlencoded). How do you send such a POST through request? Junior
  8. The POST /api/avatar endpoint expects multipart/form-data with a file in the avatar field. The variable buffer holds the bytes of the file. How do you send it in an API test? Middle
  9. The server answers 404 to GET /api/users/999. What does await request.get("/api/users/999") do with no extra options? Junior
  10. Data setup: the server answers this POST with status 422. What happens on this line? Middle
    const res = await request.post('/api/orders', {
      data: { sku: 'A-1', qty: 0 },
      failOnStatusCode: true,
    });
  11. For which HTTP statuses does res.ok() return true? Junior
  12. The gateway returned 502 with an HTML page instead of JSON. What does await res.json() do for such a response? Middle
  13. The GET /api/report.pdf endpoint returns a PDF. Which response method gives the file content without turning it into a string? Junior
  14. The test is declared as async ({ request }) => { … } and uses no page, context or browser. How does Playwright run it? Junior
  15. The server returns the header Content-Type: application/json. What does the expression res.headers()["Content-Type"] return? Junior
  16. The config sets baseURL: "http://localhost:3000/api/v2/". Which URL does request.get("/users") go to? Middle
  17. An endpoint sometimes answers 503 under load. The author adds maxRetries: 3 to the request. What does that change when the server answered 503? Middle
  18. GET /old-path on the server answers 302 with Location: /new-path. How do you check the 302 response itself and its Location header in an API test? Middle
  19. The login endpoint POST /api/login sets a session cookie in the response (Set-Cookie). How do you log in through the API once and hand this session to browser tests? Middle
  20. A file creates apiContext in beforeAll (login as user A, session in a cookie) and all tests of the file use it. Tests run sequentially in one worker. One test calls POST /api/logout (the server invalidates the session), and the following tests get 401. What is the cause and how do you fix it? Senior

Take the quiz for this chapter · Read the explanation in the knowledge base

Authentication and storageState

  1. What does storageState store? Junior
  2. What is the recommended way to log in once for all tests? Middle
  3. How do you run some tests in a file without login when storageState is set in the config? Middle
  4. Tests change the profile settings of the same user in parallel and are flaky. What do you do? Senior

Take the quiz for this chapter · Read the explanation in the knowledge base

Config, projects, parallelism, CI

  1. How are tests parallelized by default? Junior
  2. Can tests in different workers share a module-level variable? Middle
  3. What is sharding, and how do you get a single report? Middle
  4. What does the flaky status in a Playwright report mean? Middle
  5. What are projects in playwright.config for? Middle
  6. Why the webServer section in the config? Middle
  7. Tests are stable locally but flaky in CI. Where do you start? Middle
  8. How do you check a test for flakiness locally? Middle
  9. What do you need to run Playwright in a clean Linux CI container? Middle
  10. Does Playwright load .env automatically? Middle
  11. Does Playwright type-check TypeScript before running tests? Middle

Take the quiz for this chapter · Read the explanation in the knowledge base

Debugging, trace viewer, reports, flaky tests

  1. What is Trace Viewer? Junior
  2. What does trace: 'on-first-retry' mean? Middle
  3. How do you debug a test step by step? Junior
  4. What is npx playwright codegen for? Junior
  5. toHaveScreenshot() fails in CI although it passes locally. The most likely cause? Middle
  6. What does UI mode (npx playwright test --ui) give you? Junior
  7. How do you update the toHaveScreenshot baseline screenshots after an intentional design change? Middle
  8. How do you check a page's accessibility automatically in a test? Middle

Take the quiz for this chapter · Read the explanation in the knowledge base

Emulation and environment

  1. How do you test a “Your session ends in 1 min” banner that appears after 14 minutes of inactivity? Middle

Take the quiz for this chapter · Read the explanation in the knowledge base