Skip to content

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 WalmartStart practicing
3 QUESTIONS FREESign 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.
3 questions free Unlock the rest in seconds
01

How do you reuse login state across tests?

WalmartMedium
Save to ▾
Show answer
Log 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?

WalmartMedium
Save to ▾
Show answer
waitForSelector is a lower-level wait; locator assertions are preferred as they retry and are more readable.
03

What does the optional chaining operator do?

WalmartMedium
Save to ▾
Show answer
obj?.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?

WalmartMedium
Save to ▾
Show answer
Use 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?

WalmartMedium
Save to ▾
Show answer
Send invalid payloads or missing auth and assert 400, 401 or 404 codes and the error message bodies.
06

How do you work with iframes?

Save to ▾
Show answer
const 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?

WalmartMedium
Save to ▾
Show answer
Log in with request.post, call request.storageState(), and create a browser context using that state.
08

What are generics in TypeScript?

WalmartMedium
Save to ▾
Show answer
Placeholders 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?

Save to ▾
Show answer
Run 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?

WalmartMedium
Save to ▾
Show answer
Use --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?

WalmartMedium
Save to ▾
Show answer
Fetch 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?

Save to ▾
Show answer
A 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?

WalmartMedium
Save to ▾
Show answer
Use 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?

Save to ▾
Show answer
const [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?

WalmartMedium
Save to ▾
Show answer
Add 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?

Save to ▾
Show answer
Before 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?

WalmartMedium
Save to ▾
Show answer
Set 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?

WalmartMedium
Save to ▾
Show answer
Use 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?

WalmartMedium
Save to ▾
Show answer
Use 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?

WalmartMedium
Save to ▾
Show answer
Use 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?

Save to ▾
Show answer
An 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?

WalmartMedium
Save to ▾
Show answer
setInputFiles 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?

WalmartMedium
Save to ▾
Show answer
await request.post('/api/users', { data: { name: 'Asha' } }) automatically sets JSON headers and serialises the payload.
24

What are web-first assertions?

WalmartMedium
Save to ▾
Show answer
Assertions like expect(locator).toBeVisible() that retry until they pass or time out, unlike one-off checks.
25

What happens if you forget an await?

WalmartMedium
Save to ▾
Show answer
The 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?

WalmartMedium
Save to ▾
Show answer
Workflow: 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?

WalmartMedium
Save to ▾
Show answer
click 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?

Save to ▾
Show answer
API 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?

WalmartMedium
Save to ▾
Show answer
Use 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?

WalmartMedium
Save to ▾
Show answer
Destructuring 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?

WalmartMedium
Save to ▾
Show answer
The 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?

WalmartMedium
Save to ▾
Show answer
const [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?

WalmartMedium
Save to ▾
Show answer
Capture 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?

Save to ▾
Show answer
Turn 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?

Save to ▾
Show answer
Define projects for chromium, firefox and webkit in playwright.config.ts, set workers, then run: npx playwright test
36

Which locators does Playwright recommend?

WalmartMedium
Save to ▾
Show answer
User-facing ones: getByRole, getByText, getByLabel, getByPlaceholder and getByTestId, which are more resilient than CSS or XPath.
37

How do you handle iframes in Playwright?

WalmartMedium
Save to ▾
Show answer
Use 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?

Save to ▾
Show answer
Separate 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?

WalmartMedium
Save to ▾
Show answer
Both 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?

WalmartMedium
Save to ▾
Show answer
Synchronous 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?

WalmartMedium
Save to ▾
Show answer
A 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?

Save to ▾
Show answer
npm 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?

WalmartMedium
Save to ▾
Show answer
beforeEach runs the same code before every test in scope; fixtures are lazy, composable and only set up what a test uses.
44

What is hoisting?

WalmartMedium
Save to ▾
Show answer
Declarations 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?

WalmartMedium
Save to ▾
Show answer
Install 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?

WalmartMedium
Save to ▾
Show answer
Use expect(page).toHaveScreenshot() to compare with stored baselines, with thresholds and masks for dynamic regions.
47

What are soft assertions?

WalmartMedium
Save to ▾
Show answer
await 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?

WalmartMedium
Save to ▾
Show answer
Playwright locators pierce open shadow roots by default, so getByRole and CSS locators work without special handling.
49

What is codegen?

WalmartMedium
Save to ▾
Show answer
npx playwright codegen records user actions and generates test code with suggested locators, handy for starting tests.
50

How does Playwright's trace viewer help?

WalmartMedium
Save to ▾
Show answer
It 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?

WalmartMedium
Save to ▾
Show answer
locator.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?

WalmartMedium
Save to ▾
Show answer
Fixtures 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?

WalmartMedium
Save to ▾
Show answer
Files 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?

Save to ▾
Show answer
A 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?

WalmartMedium
Save to ▾
Show answer
Playwright 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?

WalmartMedium
Save to ▾
Show answer
Use 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?

Save to ▾
Show answer
npx 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?

Save to ▾
Show answer
Cover happy path, validation errors, auth and permissions, boundary values, idempotency, schema, performance and data cleanup.