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
- How does Playwright control the browser? Junior
- Which browser engines does Playwright support? Junior
- What is the fundamental difference between Playwright and Selenium? Middle
- 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
- What is a BrowserContext? Junior
- What is the object hierarchy in Playwright? Junior
- How do you get the page that opens in a new tab after a click? Middle
// ?
await page.getByRole('link', { name: 'Contract' }).click();
// ?
- How do you test a chat between two users in one test? Middle
- 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
- Which locators does Playwright recommend preferring? Junior
- What is a Locator in Playwright? Junior
- How does a Locator differ from an ElementHandle? Middle
- The page has three “Delete” buttons. What happens? Middle
await page.getByRole('button', { name: 'Delete' }).click();
- 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
- Which attribute does getByTestId look for by default? Middle
- How do you work with an element inside an iframe? Middle
- Do Playwright CSS locators see elements in the Shadow DOM? Senior
- What does the
exact: true option do in getByRole('button', { name: 'Save', exact: true })? Junior - How do you find a product card that contains a “Buy” button but no “Out of stock” badge? Middle
- What is
locator.or() for? Middle - Why is
locator.first() risky as the main way around strict mode? Middle - What does
await page.getByRole('listitem').all() return right after goto if the list is still loading? Middle - How does
getByText('Total') differ from getByText('Total', { exact: true })? Junior - Why is
getByRole considered better than CSS even for internal admin panels? Middle - What does
toMatchAriaSnapshot() check? Middle
Take the quiz for this chapter · Read the explanation in the knowledge base
Auto-waiting and web-first assertions
- What does Playwright check before click() (auto-waiting)? Junior
- The text updates a second after the page loads. Which check is reliable? Middle
- What happens if you forget await before an assertion? Middle
expect(page.getByText('Success')).toBeVisible();
- How do you reliably check that a list has 10 products that load asynchronously? Middle
- Why is page.waitForTimeout(3000) considered an anti-pattern? Middle
- How do you wait for a condition that no built-in assertion checks (for example, a status in the database)? Middle
- What is expect.soft? Junior
- How does
toBeAttached() differ from toBeVisible()? Junior - Which assertion best checks that a spinner has disappeared? Junior
- How does
toHaveText differ from toContainText? Middle - What is
await expect(async () => { ... }).toPass() for? Middle - How do you reliably wait for the page change after logging in? Middle
- 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
- How does
fill() differ from pressSequentially()? Middle - What does the
{ force: true } option do in click()? Middle - 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
- What are fixtures in @playwright/test? Junior
- 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();
},
});
- When does a fixture run that neither the test, nor its hooks, nor other fixtures in use request? Middle
- How does a scope: 'worker' fixture differ from a 'test' one? Middle
- Why are fixtures often better than beforeEach? Middle
- Why use test.step() in a test? Middle
- How do you tag a test and run only smoke tests? Middle
- What happens to the tests in a file with
test.describe.configure({ mode: 'serial' }) if the second test fails? Middle - 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
- What is page.route() for? Junior
- How do you replace an API response with a 500 error? Middle
- How do you change one field in a real server response? Middle
- How do you wait for a specific response after a click and check it? Middle
- How do you wait for a request to be sent and check its body? Middle
- How do you add an authorization header to every API request the page itself makes, without changing the app code? Middle
- 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
- What is the request fixture? Junior
- Does page.route() intercept requests sent with the request fixture? Middle
- 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();
});
- The test logged in through the UI. Does the same session go into page.request.get() and into the request fixture? Middle
- 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
- How do you pass the query parameters isbn=1234 and page=2 in a GET request through the request fixture? Junior
- The server accepts the login as an HTML form (application/x-www-form-urlencoded). How do you send such a POST through request? Junior
- 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
- The server answers 404 to GET /api/users/999. What does await request.get("/api/users/999") do with no extra options? Junior
- 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,
});
- For which HTTP statuses does res.ok() return true? Junior
- The gateway returned 502 with an HTML page instead of JSON. What does await res.json() do for such a response? Middle
- The GET /api/report.pdf endpoint returns a PDF. Which response method gives the file content without turning it into a string? Junior
- The test is declared as async ({ request }) => { … } and uses no page, context or browser. How does Playwright run it? Junior
- The server returns the header Content-Type: application/json. What does the expression res.headers()["Content-Type"] return? Junior
- The config sets baseURL: "http://localhost:3000/api/v2/". Which URL does request.get("/users") go to? Middle
- 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
- 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
- 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
- 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
- What does storageState store? Junior
- What is the recommended way to log in once for all tests? Middle
- How do you run some tests in a file without login when storageState is set in the config? Middle
- 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
- How are tests parallelized by default? Junior
- Can tests in different workers share a module-level variable? Middle
- What is sharding, and how do you get a single report? Middle
- What does the flaky status in a Playwright report mean? Middle
- What are projects in playwright.config for? Middle
- Why the webServer section in the config? Middle
- Tests are stable locally but flaky in CI. Where do you start? Middle
- How do you check a test for flakiness locally? Middle
- What do you need to run Playwright in a clean Linux CI container? Middle
- Does Playwright load
.env automatically? Middle - 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
- What is Trace Viewer? Junior
- What does trace: 'on-first-retry' mean? Middle
- How do you debug a test step by step? Junior
- What is npx playwright codegen for? Junior
- toHaveScreenshot() fails in CI although it passes locally. The most likely cause? Middle
- What does UI mode (
npx playwright test --ui) give you? Junior - How do you update the
toHaveScreenshot baseline screenshots after an intentional design change? Middle - 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
- 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