Learn › Playwright Testing › Interview Questions › Company-wise › Walmart Walmart Playwright Testing Interview Questions & Answers Curated interview practice questions with answers. These are practice scenarios, not a verified list of past interview questions.
Solved for Walmart Start practicing
3 QUESTIONS FREE Sign up or log in to unlock the full question bank and track your progress. Unlock every question and answer, then continue practising company-wise and package-wise.
Sign up free Log in
01 How do you reuse login state across tests? Show answerLog in once in global setup, save storageState to a JSON file and set use.storageState in the config so every test starts logged in.
02 What is the difference between waitForSelector and expect with locator? Show answerwaitForSelector is a lower-level wait; locator assertions are preferred as they retry and are more readable.
03 What does the optional chaining operator do? Show answerobj?.a?.b safely reads nested properties and returns undefined instead of throwing if something in the chain is missing.
04 How do you manage test data and environments? Show answerUse environment variables or .env files, a baseURL in config, API calls for setup and cleanup, and unique data per run.
05 How do you test API error scenarios? Show answerSend invalid payloads or missing auth and assert 400, 401 or 404 codes and the error message bodies.
06 How do you work with iframes? Show answerconst frame = page.frameLocator('#payment-frame');
await frame.getByLabel('Card number').fill('4111 1111 1111 1111');
07 How do you share cookies between API login and UI? Show answerLog in with request.post, call request.storageState(), and create a browser context using that state.
08 What are generics in TypeScript? Show answerPlaceholders for types that make reusable code type-safe, for example a helper function returning the same type of item that it receives.
09 How do you reduce the execution time of a 2000-test suite? Show answerRun in parallel with sharding, reuse authentication state, set up data through APIs, avoid unnecessary waits, run smoke on every commit and the full suite nightly.
10 How do you debug a Playwright test? Show answerUse --debug or the Inspector, page.pause(), UI mode, the trace viewer and headed runs with slowMo.
11 How do you handle token refresh in long API test runs? Show answerFetch tokens in a fixture with expiry tracking and refresh it when it is about to expire, keeping tests unaware of the details.
12 What are arrow functions? Show answerA short function syntax that does not have its own this and arguments, taking them from the surrounding scope.
13 How do you shard tests across machines? Show answerUse npx playwright test --shard=1/4 in each CI job and merge reports afterwards to reduce total run time.
14 How do you handle a new tab? Show answerconst [newPage] = await Promise.all([
context.waitForEvent('page'),
page.getByText('Open').click(),
]);
await newPage.waitForLoadState();
15 How do you handle rate limits or slow APIs in tests? Show answerAdd retries with backoff for the API step, set a suitable timeout, and use mocks for non-critical dependencies.
16 What is auto-waiting in Playwright? Show answerBefore acting, Playwright waits for the element to be attached, visible, stable, enabled and able to receive events — so manual waits are rarely needed.
17 How do you send authentication headers? Show answerSet extraHTTPHeaders in the config or pass headers per request, for example Authorization: Bearer token fetched in a setup step.
18 How do you mock third-party APIs in UI tests? Show answerUse page.route to intercept the call and fulfil it with fixed JSON so tests do not depend on external systems.
19 How do you set test timeouts? Show answerUse timeout and expect.timeout in config, test.setTimeout() for one test and test.slow() for known slower tests.
20 How do you run tests on mobile viewports? Show answerUse device descriptors such as devices['iPhone 13'] in a project config to emulate viewport, user agent and touch.
21 What is a locator in Playwright? Show answerAn object describing how to find an element, re-evaluated on every action so it always targets the current DOM.
22 How do you handle file uploads and downloads? Show answersetInputFiles on the input for uploads; for downloads wait on page.waitForEvent('download') and save or inspect the file.
23 How do you send a POST request with a JSON body? Show answerawait request.post('/api/users', { data: { name: 'Asha' } }) automatically sets JSON headers and serialises the payload.
24 What are web-first assertions? Show answerAssertions like expect(locator).toBeVisible() that retry until they pass or time out, unlike one-off checks.
25 What happens if you forget an await? Show answerThe action runs without waiting, so the next step may run first — causing flaky failures or 'Target closed' errors. The @typescript-eslint/no-floating-promises rule catches it.
26 How do you run Playwright in GitHub Actions? Show answerWorkflow: checkout → setup-node → npm ci → npx playwright install --with-deps → npx playwright test → upload playwright-report as an artifact.
27 What is the difference between click and dispatchEvent? Show answerclick simulates a real user click with actionability checks; dispatchEvent fires a DOM event directly without those checks.
28 What is the difference between API testing and UI testing? Show answerAPI testing checks services directly and is fast and stable; UI testing checks the full user experience in the browser and is slower.
29 How do you run tests in Docker? Show answerUse the official Playwright image which contains browsers and dependencies, mount the project and run npx playwright test for consistent CI environments.
30 What is destructuring and the spread operator? Show answerDestructuring pulls values from arrays or objects into variables; spread expands an array or object into another, useful for copying and merging config.
31 What is APIRequestContext? Show answerThe object behind the request fixture that holds base URL, headers and cookies, and can share cookies with a browser context.
32 How do you test a file download? Show answerconst [download] = await Promise.all([
page.waitForEvent('download'),
page.getByText('Export').click(),
]);
await download.saveAs('reports/file.csv');
33 How do you test file downloads and verify their content? Show answerCapture the download event, save it with download.saveAs, then read the file in Node and assert on name, size or content.
34 Tests are flaky in CI. How do you debug them? Show answerTurn on trace: 'on-first-retry', open the trace viewer, check network and timing, replace hard waits with web-first assertions, isolate test data and check for sharding conflicts.
35 How do you run tests on three browsers in parallel? Show answerDefine projects for chromium, firefox and webkit in playwright.config.ts, set workers, then run: npx playwright test
36 Which locators does Playwright recommend? Show answerUser-facing ones: getByRole, getByText, getByLabel, getByPlaceholder and getByTestId, which are more resilient than CSS or XPath.
37 How do you handle iframes in Playwright? Show answerUse page.frameLocator('#frame').getByRole(...) so actions work inside the iframe with auto-waiting.
38 How would you structure a large Playwright framework for a team? Show answerSeparate tests, page objects, fixtures, utilities, test data and config; use tags, projects, shared auth setup, linting, code review and a CI pipeline with sharding and reports.
39 What are interfaces and types in TypeScript? Show answerBoth describe the shape of data. Interfaces are extendable and suit object contracts; type aliases can also model unions and primitives.
40 What is the difference between synchronous and asynchronous code? Show answerSynchronous code runs line by line and blocks; asynchronous code starts a task and continues, handling the result later with promises or await.
41 What is the difference between a type and an enum in TypeScript? Show answerA type alias describes a shape or union of values; an enum creates a named set of constants that exists at runtime.
42 What is npm and package.json? Show answernpm is the Node package manager. package.json lists the project's dependencies and scripts, such as the command that runs the tests.
43 What is the difference between beforeEach and fixtures? Show answerbeforeEach runs the same code before every test in scope; fixtures are lazy, composable and only set up what a test uses.
Show answerDeclarations of var and functions are moved to the top of their scope at compile time; let and const are hoisted but stay in the temporal dead zone until declared.
45 How do you integrate Playwright with Allure or other reports? Show answerInstall the allure-playwright reporter, add it in the config reporters array and generate the report from the allure-results folder in CI.
46 How do you do visual regression testing? Show answerUse expect(page).toHaveScreenshot() to compare with stored baselines, with thresholds and masks for dynamic regions.
47 What are soft assertions? Show answerawait expect.soft(locator).toHaveText('...') records the failure but lets the test continue, so you see every mismatch in one run.
48 How do you handle shadow DOM? Show answerPlaywright locators pierce open shadow roots by default, so getByRole and CSS locators work without special handling.
Show answernpx playwright codegen records user actions and generates test code with suggested locators, handy for starting tests.
50 How does Playwright's trace viewer help? Show answerIt records screenshots, DOM snapshots, network calls and actions per step so you can replay a failed run and see exactly what happened.
51 How do you perform drag and drop and hover? Show answerlocator.hover() and locator.dragTo(target) perform these actions, with auto-waiting for actionability.
52 What are fixtures and how do you create a custom one? Show answerFixtures set up and tear down test dependencies. Extend with test.extend({ loggedInPage: async ({ page }, use) => { ...; await use(page); } }).
53 How do you run tests in parallel and control workers? Show answerFiles run in parallel by default; set workers in the config and use test.describe.configure({ mode: 'parallel' }) for tests inside a file.
54 Locator vs ElementHandle? Show answerA Locator is lazy, re-resolved on every action and auto-waits (recommended). An ElementHandle points to one DOM node and can go stale.
55 How does Playwright compare with Selenium and Cypress? Show answerPlaywright supports multiple browsers, tabs, languages and has auto-waiting and tracing; Selenium has the widest ecosystem; Cypress runs in-browser with a great UI but has more limits across tabs.
56 How do you test file upload via API? Show answerUse request.post with multipart: { file: { name, mimeType, buffer } } and assert the response and stored file details.
57 How do you run a single test or file in Playwright? Show answernpx playwright test tests/login.spec.ts, add -g "test title" to match a name, or use test.only while debugging.
58 How would you design API test coverage for a new endpoint? Show answerCover happy path, validation errors, auth and permissions, boundary values, idempotency, schema, performance and data cleanup.