SoftwareTestPilot
300 Playwright Q&A

300 Playwright Interview Questions & Answers (1970) — Land Your SDET Role

A definitive bank of 300 real Playwright interview questions with senior-level answers. Covers fundamentals, locators, assertions, fixtures, API testing, network mocking, authentication, debugging, tracing, CI/CD, Docker, and framework design — for freshers through SDET architects.

  • 49 min read
  • Difficulty: Mixed (Easy → Hard)
  • Freshers → 10+ yrs
  • Updated June 1970
  • Avinash Kamble

1. Playwright Fundamentals

Medium Very Common 1 min read

Q1.What is Playwright?

Playwright is an open-source browser automation framework developed by Microsoft. It is used for end-to-end testing of web applications across Chromium, Firefox, and WebKit. It supports modern testing features such as auto-waiting, browser contexts, tracing, network interception, and parallel execution. Playwright is popular because it reduces flaky tests and provides strong developer experience. For a full walkthrough, read our Playwright complete guide and the official Playwright documentation.

Easy Very Common 1 min read

Q2.Why is Playwright used in automation testing?

Playwright is used to automate browser-based testing for modern web applications. It can test user flows, forms, navigation, authentication, file upload, downloads, and cross-browser behavior. Teams prefer it because it includes auto-waiting, fast execution, built-in test runner, screenshots, videos, trace viewer, and API testing support.

Easy Very Common 1 min read

Q3.Which browsers does Playwright support?

Playwright supports Chromium, Firefox, and WebKit browser engines. This means it can test applications on Chrome, Edge, Firefox, and Safari-like environments. Its WebKit support is especially useful for validating Safari behavior on non-macOS CI environments.

Easy Very Common 1 min read

Q4.Which programming languages are supported by Playwright?

Playwright supports TypeScript, JavaScript, Python, Java, and .NET. TypeScript is the most common choice because Playwright Test is highly optimized for Node.js and provides strong typing, better autocomplete, and easier framework maintenance.

Easy Very Common 1 min read

Q5.What is Playwright Test?

Playwright Test is the official test runner provided by Playwright. It supports fixtures, assertions, retries, parallel execution, projects, reporters, tracing, screenshots, and videos. It removes the need for separate test runners like Jest or Mocha in most Playwright projects.

Easy Very Common 1 min read

Q6.How is Playwright different from traditional browser automation tools?

Playwright is designed for modern web apps. It uses auto-waiting, isolated browser contexts, built-in parallel execution, native network interception, and trace debugging. Unlike older tools that require many manual waits and separate drivers, Playwright provides a more integrated automation experience.

Easy Very Common 1 min read

Q7.What is the difference between a browser and a browser engine in Playwright?

A browser is the actual application users interact with, such as Chrome or Firefox. A browser engine is the underlying rendering engine, such as Chromium, Firefox, or WebKit. Playwright automates browser engines to provide cross-browser coverage.

Easy Very Common 1 min read

Q8.What is headless mode in Playwright?

Headless mode runs the browser without opening a visible UI. It is faster and commonly used in CI/CD pipelines. Playwright also supports headed mode, where the browser opens visibly, which is useful during debugging and test development.

Medium Very Common 1 min read

Q9.Why do many teams choose Playwright over Selenium?

Teams choose Playwright over Selenium because Playwright has built-in auto-waiting, faster parallel execution, browser contexts, network mocking, trace viewer, and simpler setup. Selenium is still widely used, but Playwright is often preferred for new modern web automation projects. Read the detailed comparison in our Playwright vs Selenium guide and our Selenium interview questions page.

Easy Very Common 1 min read

Q10.How is Playwright different from Cypress?

Playwright supports Chromium, Firefox, and WebKit, while Cypress mainly focuses on browser testing with a different execution model. Playwright supports multiple tabs, multiple browser contexts, native downloads, API testing, and stronger cross-browser support. Cypress has strong developer tooling but different architectural limitations.

Easy Very Common 1 min read

Q11.What are the main advantages of Playwright?

The main advantages are auto-waiting, reliable locators, cross-browser support, fast parallel execution, browser context isolation, network interception, API testing, trace viewer, screenshots, videos, and built-in reporting. These features help teams build stable automation frameworks faster.

Easy Very Common 1 min read

Q12.What are the limitations of Playwright?

Playwright is mainly focused on web testing, not native mobile or desktop application testing. It requires programming knowledge and may need extra setup for complex enterprise environments. Some real Safari behavior still requires testing on actual Safari devices, even though WebKit coverage is strong.

Easy Very Common 1 min read

Q13.What types of testing can be done with Playwright?

Playwright can be used for end-to-end UI testing, regression testing, smoke testing, cross-browser testing, API testing, visual testing, accessibility checks, authentication testing, and network mocking. It is commonly used by QA automation engineers and SDETs.

Easy Very Common 1 min read

Q14.What is auto-waiting in Playwright?

Auto-waiting means Playwright automatically waits for elements to be ready before performing actions. For example, before clicking a button, it checks whether the element is attached, visible, stable, enabled, and able to receive events. This reduces the need for manual waits.

Easy Very Common 1 min read

Q15.What is a locator in Playwright?

A locator is Playwright’s recommended way to find and interact with elements. Locators are lazy and retry automatically until the element is available. Examples include page.getByRole(), page.getByText(), page.getByLabel(), and page.locator().

Easy Very Common 1 min read

Q16.What is a browser context in Playwright?

A browser context is an isolated browser session inside a browser instance. Each context has separate cookies, local storage, session storage, and permissions. It behaves like an incognito session and helps tests run independently in parallel.

Easy Very Common 1 min read

Q17.Why is TypeScript popular with Playwright?

TypeScript is popular because Playwright’s official runner works very well with Node.js and TypeScript. TypeScript provides type safety, better IDE support, autocomplete, fewer runtime errors, and easier maintenance for large automation frameworks.

Easy Very Common 1 min read

Q18.Does Playwright require browser drivers like Selenium?

No. Playwright does not require separate browser drivers like ChromeDriver or GeckoDriver. It downloads and manages browser binaries automatically. This simplifies setup and avoids many driver-version mismatch issues common in Selenium projects.

Easy Very Common 1 min read

Q19.What is test isolation in Playwright?

Test isolation means each test runs independently without sharing browser state such as cookies, sessions, or local storage. Playwright achieves this using browser contexts. Good isolation prevents one test from affecting another and improves reliability.

Easy Very Common 1 min read

Q20.Can Playwright be used in CI/CD pipelines?

Yes. Playwright is highly suitable for CI/CD pipelines. It supports headless execution, retries, parallel workers, sharding, HTML reports, JUnit reports, screenshots, videos, traces, and official Docker images. It integrates well with GitHub Actions, Jenkins, GitLab CI, and Azure DevOps.

Easy Very Common 1 min read

Q21.Is Playwright good for cross-browser testing?

Yes. Playwright is very strong for cross-browser testing because it supports Chromium, Firefox, and WebKit with one API. Teams can define browser projects in the Playwright config and run the same test suite across multiple browsers.

Easy Very Common 1 min read

Q22.What are real-world use cases of Playwright?

Real-world use cases include testing login flows, checkout journeys, dashboards, admin portals, role-based access, file upload/download, email verification flows, API-driven setup, network error states, and regression suites for modern single-page applications.

Easy Very Common 1 min read

Q23.Why are Playwright tests usually less flaky?

Playwright tests are less flaky because of auto-waiting, web-first assertions, locator retrying, test isolation, browser contexts, trace viewer, and controlled network mocking. However, bad locators, unstable test data, and hard waits can still create flaky tests.

Easy Very Common 1 min read

Q24.What is tracing in Playwright?

Tracing records detailed test execution information such as screenshots, DOM snapshots, network calls, console logs, and actions. The trace viewer helps debug failures step by step. It is very useful for CI failures because developers can inspect what happened without rerunning locally.

Easy Very Common 1 min read

Q25.Who should learn Playwright?

QA engineers, automation testers, SDETs, frontend developers, and test architects should learn Playwright. It is especially useful for teams working on modern web applications, CI/CD automation, and scalable test frameworks. Practice live with our AI Mock Interview or hands-on exercises in the QA Practice Hub.

Confidence check

If you can confidently answer the Playwright Fundamentals 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. Installation, Setup, and Configuration

Easy Very Common 1 min read

Q26.How do you install Playwright?

The easiest way is to run: npm init playwright@latest. This installs Playwright, creates a basic test structure, adds configuration, and prompts you to install browsers. It is the recommended setup for new TypeScript or JavaScript projects. For a step-by-step setup, see our Playwright installation guide.

Easy Very Common 1 min read

Q27.What files are generated during Playwright setup?

A typical setup generates playwright.config.ts, a tests folder, example test files, package.json updates, and sometimes a tests-examples folder. It also installs required dependencies and browser binaries if selected during setup.

Easy Very Common 1 min read

Q28.What is playwright.config.ts?

playwright.config.ts is the main configuration file for Playwright Test. It defines test directory, timeout, retries, workers, reporters, projects, browser options, baseURL, screenshots, videos, traces, and global setup or teardown settings.

Easy Very Common 1 min read

Q29.What is testDir in Playwright config?

testDir tells Playwright where test files are located. For example, testDir: './tests' means Playwright will search inside the tests folder for test files. It helps organize test suites clearly.

Easy Very Common 1 min read

Q30.What is timeout in Playwright?

Timeout defines the maximum time allowed for a test or action before it fails. Playwright supports global test timeout, expect timeout, action timeout, and navigation timeout. Proper timeout configuration helps avoid hanging tests.

Easy Very Common 1 min read

Q31.What are retries in Playwright?

Retries allow failed tests to run again automatically. This is commonly used in CI to reduce the impact of temporary environment issues. However, retries should not hide real flakiness; failures should still be analyzed using traces and reports.

Easy Very Common 1 min read

Q32.What are workers in Playwright?

Workers are parallel processes used to run tests. Increasing workers can reduce execution time, but too many workers can overload the application or test environment. Worker count should be tuned based on infrastructure capacity.

Easy Very Common 1 min read

Q33.What are projects in Playwright?

Projects allow the same test suite to run with different configurations. For example, one project can run tests on Chromium, another on Firefox, and another on WebKit. Projects can also represent mobile devices, roles, or environments.

Easy Very Common 1 min read

Q34.What is the use option in Playwright config?

The use option defines shared settings for tests, such as browserName, baseURL, viewport, storageState, trace, screenshot, video, permissions, locale, and timezone. It avoids repeating common configuration in every test.

Easy Very Common 1 min read

Q35.What is baseURL in Playwright?

baseURL defines the base address for navigation. If baseURL is set to https://example.com, then page.goto('/login') opens https://example.com/login. It makes tests cleaner and environment switching easier.

Easy Very Common 1 min read

Q36.How do you configure reporters in Playwright?

Reporters are configured in playwright.config.ts using the reporter property. Common reporters include html, list, line, json, and junit. HTML reports are useful for local debugging, while JUnit reports are useful for CI systems.

Easy Very Common 1 min read

Q37.How do you configure screenshots, videos, and traces?

They can be configured under the use section. Common settings are screenshot: 'only-on-failure', video: 'retain-on-failure', and trace: 'on-first-retry'. This keeps artifacts useful without consuming too much storage.

Easy Very Common 1 min read

Q38.What is globalSetup in Playwright?

globalSetup is a function that runs once before all tests. It is often used to perform login, create authentication storage state, seed test data, or prepare the environment before test execution starts.

Easy Very Common 1 min read

Q39.What is globalTeardown in Playwright?

globalTeardown runs once after all tests complete. It is used to clean up test data, close external resources, or reset environment state. It is useful for maintaining a clean test environment.

Easy Very Common 1 min read

Q40.How do you handle environment variables in Playwright?

Environment variables can be read using process.env. Teams often use .env files with dotenv for local runs and CI secrets for pipelines. Sensitive values such as passwords and tokens should never be hardcoded in test code.

Easy Very Common 1 min read

Q41.How do you run Playwright tests in headed mode?

You can run tests in headed mode using npx playwright test --headed. This opens the browser visibly and helps debug test behavior. Headed mode is useful during test development but not usually used in CI.

Easy Very Common 1 min read

Q42.How do you run tests in a specific browser?

You can define projects in the config and run one using npx playwright test --project=chromium. This helps validate specific browser behavior without running the entire cross-browser matrix.

Easy Very Common 1 min read

Q43.How do you add npm scripts for Playwright?

You can add scripts in package.json, such as "test:e2e": "playwright test", "test:headed": "playwright test --headed", and "report": "playwright show-report". Scripts make commands easier for team members and CI pipelines.

Easy Very Common 1 min read

Q44.How does Playwright support TypeScript?

Playwright supports TypeScript out of the box. You can write .ts test files without manual transpilation setup. TypeScript improves maintainability by catching type errors early and providing better editor support.

Easy Very Common 1 min read

Q45.How do you install Playwright browsers?

You can install browsers using npx playwright install. For CI environments, npx playwright install --with-deps installs browsers and required system dependencies. This is important for Linux-based build agents.

Easy Very Common 1 min read

Q46.What does fullyParallel mean in Playwright?

fullyParallel allows tests within files to run in parallel, not just separate files. It can speed up execution but requires tests to be fully independent. Shared state must be avoided when using full parallel mode.

Easy Very Common 1 min read

Q47.How do you run tests using tags or grep?

Playwright supports grep and grepInvert in config or command line. Example: npx playwright test --grep @smoke. Tags help run smoke, regression, critical, or feature-specific test subsets.

Easy Very Common 1 min read

Q48.How do you manage different environments in Playwright?

Use environment variables, separate config files, or conditional baseURL values. For example, BASE_URL can point to dev, QA, staging, or production. Avoid hardcoding environment-specific URLs inside tests.

Easy Very Common 1 min read

Q49.What are common Playwright setup mistakes?

Common mistakes include hardcoding URLs, committing secrets, using too many global dependencies, not configuring traces, ignoring test isolation, using brittle selectors, and running all tests serially. A good setup should be simple, isolated, and CI-friendly.

Medium Very Common 1 min read

Q50.Write a basic Playwright test.

A simple Playwright test navigates to a page and verifies content. ``ts import { test, expect } from '@playwright/test'; test('homepage title should be visible', async ({ page }) => { await page.goto('/'); await expect(page.getByRole('heading')).toBeVisible(); }); `` This uses the page fixture, a relative URL, and a web-first assertion.

Confidence check

If you can confidently answer the Installation, Setup, and Configuration 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. Locators and Selectors

Easy Very Common 1 min read

Q51.What is a locator in Playwright?

A locator represents a way to find an element on the page. It is lazy, auto-retrying, and preferred for actions and assertions. Locators wait for elements to become available, making tests more stable than using raw selectors directly.

Easy Very Common 1 min read

Q52.What is the difference between locator and selector?

A selector is a string used to identify elements, while a locator is a Playwright object that resolves elements at action time. Locators retry automatically and work better with dynamic pages. Selectors are lower-level and more brittle if overused.

Easy Very Common 1 min read

Q53.What is getByRole in Playwright?

getByRole finds elements by their accessible role, such as button, link, checkbox, or heading. It is one of the best locator strategies because it matches how users and assistive technologies understand the page.

Easy Very Common 1 min read

Q54.What is getByText in Playwright?

getByText finds elements by visible text. It is useful for buttons, labels, messages, and static content. However, if text changes frequently due to localization or UI updates, role-based or test-id locators may be more stable.

Easy Very Common 1 min read

Q55.What is getByLabel in Playwright?

getByLabel finds form controls using their associated label text. It is useful for inputs, checkboxes, radio buttons, and textareas. It encourages accessible HTML because labels must be properly connected to controls.

Easy Very Common 1 min read

Q56.What is getByPlaceholder in Playwright?

getByPlaceholder finds input elements by placeholder text. It is helpful for simple forms but should not be the first choice when labels are available. Placeholder text can change often and is not always ideal for accessibility.

Easy Very Common 1 min read

Q57.What is getByTestId in Playwright?

getByTestId finds elements using a dedicated test attribute such as data-testid. It is useful when user-facing locators are unstable. Teams often use test IDs for complex components, icons, dynamic grids, and repeated elements.

Easy Very Common 1 min read

Q58.Can CSS selectors be used in Playwright?

Yes. CSS selectors can be used with page.locator('css-selector'). They are useful for technical targeting but can become brittle if tied to layout or styling classes. Prefer role, label, text, or test ID locators when possible.

Easy Very Common 1 min read

Q59.Can XPath be used in Playwright?

Yes, XPath can be used, but it is generally not recommended as the default locator strategy. XPath expressions are often harder to read and maintain. Use XPath only when better locator options are not available.

Easy Very Common 1 min read

Q60.What is locator chaining?

Locator chaining means narrowing down elements step by step. For example, page.getByRole('list').getByRole('button', { name: 'Delete' }) targets a button inside a specific list. Chaining improves readability and reduces ambiguity.

Easy Very Common 1 min read

Q61.What is locator filtering?

Filtering narrows a locator using conditions such as hasText or has. It is useful when multiple similar elements exist. For example, a product card can be filtered by product name before clicking its Add to Cart button.

Easy Very Common 1 min read

Q62.What are first(), last(), and nth() in Playwright?

first(), last(), and nth(index) select a specific element from a list of matching elements. They are useful for repeated elements, but overuse can make tests fragile. Prefer unique user-facing locators when possible.

Easy Very Common 1 min read

Q63.What is locator strictness?

Playwright locators are strict by default for actions. If a locator matches multiple elements and an action expects one, Playwright throws an error. This prevents accidental clicks on the wrong element and encourages precise locators.

Easy Very Common 1 min read

Q64.How do you handle dynamic elements in Playwright?

Use stable locators, web-first assertions, and avoid fixed waits. Since locators retry automatically, Playwright can handle elements that appear after rendering. For dynamic lists, filter by meaningful text or test ID.

Easy Very Common 1 min read

Q65.Why are accessibility-first locators recommended?

Accessibility-first locators such as getByRole and getByLabel reflect how users interact with the application. They improve test reliability and encourage accessible UI development. They are also less tied to implementation details like CSS classes.

Easy Very Common 1 min read

Q66.How does Playwright handle shadow DOM?

Playwright’s CSS and text locators can pierce open shadow DOM by default. This makes it easier to test web components. Closed shadow DOM cannot be accessed directly because it is intentionally hidden by the browser.

Easy Very Common 1 min read

Q67.What is frameLocator?

frameLocator is used to locate elements inside iframes. It first identifies the frame and then locates elements inside it. This is more reliable than manually switching frame references in many cases.

Easy Very Common 1 min read

Q68.How do you count elements using locators?

You can use await locator.count() to get the number of matched elements. This is useful for validating tables, lists, search results, notifications, or repeated UI components.

Easy Very Common 1 min read

Q69.When should you use getByText instead of getByRole?

Use getByText when verifying static visible content or messages. Use getByRole for interactive elements such as buttons and links. Role locators are generally better for actions, while text locators are useful for content assertions.

Easy Very Common 1 min read

Q70.What are has and hasText filters?

has filters a locator by another locator inside it, while hasText filters by contained text. They are useful for targeting a specific card, row, or panel based on internal content before performing an action.

Easy Very Common 1 min read

Q71.What is a stable locator strategy?

A stable locator strategy prioritizes getByRole, getByLabel, getByText, and getByTestId. Avoid fragile CSS classes, long XPath paths, and index-based locators. Good locators should survive UI refactoring and minor layout changes.

Easy Very Common 1 min read

Q72.What are common locator anti-patterns?

Anti-patterns include using long XPath, dynamic CSS classes, nth() without context, text that changes often, and selectors based on visual layout. These make tests brittle and difficult to maintain.

Easy Very Common 1 min read

Q73.Why should long XPath be avoided?

Long XPath depends heavily on DOM structure. Even small layout changes can break tests. Playwright provides better locator options that are more readable, user-focused, and reliable for modern applications.

Easy Very Common 1 min read

Q74.How do you customize the test ID attribute?

You can configure Playwright to use a custom test ID attribute. For example, testIdAttribute: 'data-qa' makes getByTestId use data-qa. This helps align Playwright with an existing frontend testing convention.

Medium Very Common 1 min read

Q75.Give an example of good locator usage.

Good locator usage targets elements like a user would. ``ts await page.getByRole('button', { name: 'Login' }).click(); await page.getByLabel('Email').fill('qa@example.com'); await expect(page.getByText('Welcome')).toBeVisible(); `` These locators are readable and stable.

Confidence check

If you can confidently answer the Locators and Selectors 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. Actions, Assertions, and Auto-Waiting

Easy Very Common 1 min read

Q76.How do you click an element in Playwright?

Use locator.click(). Playwright automatically waits for the element to be visible, stable, enabled, and able to receive events before clicking. Example: await page.getByRole('button', { name: 'Submit' }).click();

Easy Very Common 1 min read

Q77.What is the difference between fill and type?

fill clears an input and sets the provided value instantly. type simulates typing character by character and can include delay. For most form automation, fill is faster and more reliable. Use type when keyboard behavior must be tested.

Easy Very Common 1 min read

Q78.How do you press keyboard keys in Playwright?

Use locator.press() or page.keyboard.press(). Example: await page.getByLabel('Search').press('Enter'). This is useful for search boxes, shortcuts, form submission, and keyboard accessibility testing.

Easy Very Common 1 min read

Q79.How do you handle checkboxes and radio buttons?

Use check(), uncheck(), and setChecked(). These methods wait for actionability and verify the final state. They are better than clicking manually because they express the test intention clearly.

Easy Very Common 1 min read

Q80.How do you select dropdown values?

Use selectOption() for native select elements. You can select by value, label, or index. For custom dropdowns, interact with visible buttons and options using locators, just like a real user.

Easy Very Common 1 min read

Q81.How do you upload files in Playwright?

Use setInputFiles() on a file input locator. Example: await page.getByLabel('Upload').setInputFiles('tests/fixtures/resume.pdf'). For hidden file inputs, target the input[type=file] element directly.

Easy Very Common 1 min read

Q82.How do you hover over an element?

Use locator.hover(). Hover is useful for testing menus, tooltips, dropdowns, and hover-based UI states. Avoid relying heavily on hover for critical flows unless the product requires it.

Easy Very Common 1 min read

Q83.How do you perform drag and drop in Playwright?

Use locator.dragTo(targetLocator). It supports common drag-and-drop scenarios. For complex custom implementations, you may need lower-level mouse actions or JavaScript-based event simulation.

Easy Very Common 1 min read

Q84.How do you use keyboard actions?

Use page.keyboard for low-level keyboard input. It supports down, up, press, insertText, and typing. Keyboard actions are useful for shortcuts, accessibility checks, and rich text editors.

Easy Very Common 1 min read

Q85.How do you use mouse actions?

Use page.mouse for low-level mouse control such as move, down, up, and click at coordinates. It is useful for canvas testing or complex drag interactions, but locator-based actions are preferred for normal UI.

Easy Very Common 1 min read

Q86.What is auto-waiting for actions?

Before actions such as click or fill, Playwright waits until the element is actionable. This means the element must be attached, visible, stable, enabled, and ready to receive input. This reduces timing-related flakiness.

Easy Very Common 1 min read

Q87.What are actionability checks?

Actionability checks are conditions Playwright verifies before performing an action. These include visibility, stability, enabled state, attachment to DOM, and whether the element receives events. They ensure Playwright acts like a real user.

Easy Very Common 1 min read

Q88.What are assertions in Playwright?

Assertions verify expected application behavior. Playwright provides expect assertions such as toBeVisible, toHaveText, toHaveURL, toBeEnabled, and toHaveCount. These assertions retry automatically until timeout.

Easy Very Common 1 min read

Q89.What are web-first assertions?

Web-first assertions are Playwright assertions designed for dynamic web pages. They automatically retry until the expected condition becomes true or timeout occurs. Example: await expect(locator).toBeVisible();

Easy Very Common 1 min read

Q90.What are soft assertions?

Soft assertions allow a test to continue even if an assertion fails. They are useful when collecting multiple validation failures in one test. Use expect.soft() carefully because too many soft failures can make test results harder to interpret.

Easy Very Common 1 min read

Q91.What is expect.poll?

expect.poll repeatedly executes a function until the expected result is reached. It is useful for checking backend state, delayed UI updates, queues, or asynchronous business processes that are not tied to a single DOM element.

Easy Very Common 1 min read

Q92.What is expect.toPass?

expect.toPass retries a block of assertions until all pass or timeout occurs. It is useful for complex conditions involving multiple checks, such as API status plus UI state validation.

Easy Very Common 1 min read

Q93.What is waitForLoadState?

waitForLoadState waits for page load states such as load, domcontentloaded, or networkidle. It should be used carefully because Playwright actions and assertions already wait in many cases. Avoid unnecessary load-state waits.

Easy Very Common 1 min read

Q94.What is waitForResponse?

waitForResponse waits for a specific network response. It is useful when UI changes depend on an API call. You can wait for a URL pattern, status code, or response predicate.

Easy Very Common 1 min read

Q95.What is waitForURL?

waitForURL waits until the page URL matches a pattern or string. It is commonly used after login, redirects, or navigation flows. It is better than using arbitrary waits after clicking a navigation button.

Easy Very Common 1 min read

Q96.Why are hard waits bad?

Hard waits like waitForTimeout slow down tests and create flakiness because they guess timing instead of waiting for real conditions. Use locators, assertions, waitForResponse, or waitForURL instead.

Easy Very Common 1 min read

Q97.How do you prevent flaky tests in Playwright?

Use stable locators, web-first assertions, isolated test data, storageState for login, avoid hard waits, control network dependencies, run tests independently, and analyze failures using traces. Flakiness is usually a design problem, not a tool problem.

Easy Very Common 1 min read

Q98.How do you handle animations in Playwright?

Playwright waits for elements to be stable before actions. If animations still cause issues, reduce unnecessary animations in test environments or wait for a meaningful final state. Avoid fixed waits unless there is no better condition.

Easy Very Common 1 min read

Q99.When can auto-waiting fail?

Auto-waiting may not help when the element is visible but data is not ready, when custom JavaScript state is incomplete, or when an API response is delayed. In such cases, wait for a specific assertion, response, or UI state.

Medium Very Common 1 min read

Q100.Show an action and assertion example.

Example: ``ts await page.goto('/login'); await page.getByLabel('Email').fill('qa@example.com'); await page.getByLabel('Password').fill('Password123'); await page.getByRole('button', { name: 'Sign in' }).click(); await expect(page).toHaveURL(/dashboard/); await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible(); `` This uses user-focused locators and web-first assertions. CTA after Q100: Ready to practice these Playwright answers in a real interview format? Try AI Mock Interview → /ai-mock-interview Start Free → /login

Confidence check

If you can confidently answer the Actions, Assertions, and Auto-Waiting 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. Browser, Context, Page, Frames, and Tabs

Easy Very Common 1 min read

Q101.What is a browser object in Playwright?

The browser object represents a browser instance such as Chromium, Firefox, or WebKit. It can create browser contexts and pages. In Playwright Test, the browser fixture is usually managed automatically.

Easy Very Common 1 min read

Q102.What is a browser context?

A browser context is an isolated session within a browser. It has separate cookies, local storage, session storage, permissions, and cache. Contexts make test isolation fast and efficient.

Easy Very Common 1 min read

Q103.What is a page in Playwright?

A page represents a single browser tab or window. Most interactions such as goto, click, fill, and assertions happen on the page or locators created from the page.

Easy Very Common 1 min read

Q104.Why are browser contexts important?

Browser contexts allow tests to run independently without sharing login state or cookies. They are lighter than launching new browsers and enable fast parallel execution. This is one of Playwright’s biggest architectural advantages.

Easy Very Common 1 min read

Q105.How do you manage cookies in Playwright?

Cookies can be added, read, or cleared through browserContext methods such as addCookies(), cookies(), and clearCookies(). Cookie management is useful for authentication, personalization, and session validation tests.

Easy Very Common 1 min read

Q106.How do you manage localStorage and sessionStorage?

You can access storage using page.evaluate() or save storage using storageState. For authentication reuse, storageState is preferred because it captures cookies and localStorage in a reusable file.

Easy Very Common 1 min read

Q107.How do you handle multiple tabs?

You can wait for a new page event from the context. Example: const newPage = await context.waitForEvent('page'). This is useful when clicking a link opens a new tab.

Easy Very Common 1 min read

Q108.How do you handle popups in Playwright?

Use page.waitForEvent('popup') before the action that opens the popup. Then interact with the popup page like any other page. This handles OAuth windows, payment popups, and external links.

Easy Very Common 1 min read

Q109.How do you handle iframes?

Use frameLocator to interact with elements inside iframes. Example: page.frameLocator('#payment-frame').getByLabel('Card number').fill('4111111111111111'). This is useful for embedded widgets.

Easy Very Common 1 min read

Q110.Why is frameLocator recommended?

frameLocator provides a clean and retry-friendly way to locate elements inside frames. It avoids manual frame switching and works naturally with Playwright locators.

Easy Very Common 1 min read

Q111.How do you grant browser permissions?

Permissions can be granted in context options using permissions: ['geolocation'] or by calling context.grantPermissions(). This is useful for testing camera, microphone, clipboard, notifications, and geolocation.

Easy Very Common 1 min read

Q112.How do you test geolocation?

Create a context with geolocation coordinates and grant geolocation permission. This allows testing location-based features such as stores near me, delivery availability, or regional content.

Easy Very Common 1 min read

Q113.How do you set viewport size?

Viewport can be configured in playwright.config.ts or per test using page.setViewportSize(). Viewport testing helps validate responsive UI behavior across desktop, tablet, and mobile layouts.

Easy Very Common 1 min read

Q114.What is device emulation in Playwright?

Device emulation simulates mobile or tablet devices using predefined descriptors. It can configure viewport, user agent, device scale factor, touch support, and browser behavior. It is useful for responsive testing.

Easy Very Common 1 min read

Q115.How do you set locale and timezone?

Locale and timezone can be set in context options. This helps test date formats, currency, language-specific UI, timezone calculations, and region-specific behavior.

Easy Very Common 1 min read

Q116.What is storageState?

storageState saves browser authentication state, including cookies and localStorage. It allows tests to start already logged in without repeating login steps. This improves speed and stability.

Easy Very Common 1 min read

Q117.How do you reuse authentication sessions?

Login once in globalSetup, save storageState to a JSON file, and configure tests to use that file. This avoids repeated UI login and makes tests faster.

Easy Very Common 1 min read

Q118.Should you reuse the same page across tests?

Usually no. Each test should use a fresh page and context to maintain isolation. Reusing pages can create hidden dependencies and flaky behavior.

Easy Very Common 1 min read

Q119.Are browser contexts similar to incognito mode?

Yes. Browser contexts behave like independent incognito sessions. They do not share cookies or storage unless explicitly configured. This makes them ideal for parallel testing.

Easy Common 1 min read

Q120.How do you handle file downloads?

Use page.waitForEvent('download') before triggering the download. Then you can check the suggested filename, save the file, or validate its contents.

Easy Common 1 min read

Q121.How do you handle browser dialogs?

Use page.on('dialog') to accept, dismiss, or inspect alert, confirm, and prompt dialogs. Register the dialog handler before performing the action that triggers the dialog.

Easy Common 1 min read

Q122.How do you handle a new window?

A new window can be handled similarly to a popup or new page event. Wait for the popup or page event, then interact with the returned Page object.

Easy Common 1 min read

Q123.What options can be set at browser context level?

Context options include viewport, storageState, permissions, geolocation, locale, timezone, colorScheme, userAgent, extraHTTPHeaders, httpCredentials, and recordVideo. These options control browser behavior for tests.

Easy Common 1 min read

Q124.What causes test isolation issues?

Isolation issues happen when tests share users, data, browser state, or backend records. They often appear only in parallel execution. Use independent contexts, unique data, and cleanup strategies to avoid them.

Medium Common 1 min read

Q125.Give an example of creating a context.

Example: ``ts const context = await browser.newContext({ viewport: { width: 1280, height: 720 }, storageState: 'auth/user.json' }); const page = await context.newPage(); await page.goto('/dashboard'); `` This creates an isolated logged-in session.

Confidence check

If you can confidently answer the Browser, Context, Page, Frames, and Tabs 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.

6. Fixtures, Hooks, and Test Runner

Easy Common 1 min read

Q126.What are fixtures in Playwright?

Fixtures are reusable objects or setup logic provided to tests. Built-in fixtures include page, browser, context, request, and browserName. Custom fixtures help share page objects, test data, and services.

Easy Common 1 min read

Q127.What are built-in fixtures?

Built-in fixtures are provided by Playwright Test. Common examples are page, context, browser, request, browserName, baseURL, and testInfo. They reduce boilerplate and improve consistency.

Easy Common 1 min read

Q128.What is a custom fixture?

A custom fixture is a user-defined fixture that provides reusable setup to tests. For example, you can create a loginPage fixture, apiClient fixture, or authenticatedPage fixture.

Easy Common 1 min read

Q129.What is a test-scoped fixture?

A test-scoped fixture is created separately for each test. It is useful for page objects, test data, and any state that must not be shared between tests.

Easy Common 1 min read

Q130.What is a worker-scoped fixture?

A worker-scoped fixture is created once per worker process. It is useful for expensive setup such as creating a test account or initializing a service client. It must be safe for tests running in that worker.

Easy Common 1 min read

Q131.What is beforeEach?

beforeEach runs before every test in a scope. It is commonly used for navigation, preparing test state, or resetting page conditions. Avoid placing heavy setup in beforeEach if it slows the suite.

Easy Common 1 min read

Q132.What is afterEach?

afterEach runs after every test. It is useful for cleanup, attaching logs, resetting data, or capturing additional diagnostics. Playwright also provides testInfo to access test status and artifacts.

Easy Common 1 min read

Q133.What is beforeAll?

beforeAll runs once before all tests in a describe block. It is useful for expensive setup shared by tests. Be careful because shared state can reduce test isolation.

Easy Common 1 min read

Q134.What is afterAll?

afterAll runs once after all tests in a describe block. It is used for final cleanup, closing external resources, or deleting shared test data created in beforeAll.

Easy Common 1 min read

Q135.What is test.describe?

test.describe groups related tests. It improves readability and allows scoped hooks, annotations, and configuration. For example, all checkout tests can be grouped under test.describe('Checkout').

Easy Common 1 min read

Q136.What is test.step?

test.step divides a test into named steps. These steps appear in reports and traces, making debugging easier. It is helpful for long scenario-based tests.

Easy Common 1 min read

Q137.What are annotations in Playwright?

Annotations add metadata to tests. Built-in annotations include skip, fixme, fail, slow, and only. Custom annotations can also be used for reporting and filtering.

Easy Common 1 min read

Q138.How do tags work in Playwright?

Tags are usually added in test titles or annotations, such as @smoke or @regression. They allow selective execution using grep. Tags are useful for organizing large test suites.

Easy Common 1 min read

Q139.What is test.skip?

test.skip skips a test or group of tests. It can be unconditional or conditional. Use it when a test is not applicable for a browser, environment, or feature flag.

Easy Common 1 min read

Q140.What is test.fixme?

test.fixme marks a test as known broken or incomplete. It documents technical debt while preventing the failure from breaking the pipeline. It should be tracked and resolved.

Easy Common 1 min read

Q141.What is test.only?

test.only runs only selected tests. It is useful during local debugging but should never be committed. CI pipelines should fail if test.only is accidentally present.

Easy Common 1 min read

Q142.What is test.slow?

test.slow triples the default timeout for a test. It is useful for genuinely slow flows, but should not be used to hide performance issues or poor synchronization.

Easy Common 1 min read

Q143.How do retries work in Playwright Test?

Retries rerun failed tests based on config or command-line settings. They are useful in CI, but repeated failures should be investigated with traces. A passing retry may still indicate flaky behavior.

Easy Common 1 min read

Q144.How does parallel execution work?

Playwright runs test files in parallel by default using workers. It can also run tests within a file in parallel if fullyParallel is enabled. Tests must be independent for safe parallel execution.

Easy Common 1 min read

Q145.What is serial mode?

Serial mode runs tests in order within a describe block. It is useful for dependent flows, but should be avoided for most test suites because it reduces parallelism and can create dependencies.

Easy Common 1 min read

Q146.What is sharding in Playwright?

Sharding splits tests across multiple machines or CI jobs. Example: --shard=1/3 runs the first third of tests. It helps scale large suites and reduce pipeline duration.

Easy Common 1 min read

Q147.What are project dependencies?

Project dependencies allow one project to run before another. They are useful for setup projects, such as authentication setup before running browser tests.

Easy Common 1 min read

Q148.Can fixtures be overridden?

Yes. Playwright fixtures can be extended or overridden using test.extend(). This allows teams to customize page, context, storageState, or custom services for specific test needs.

Easy Common 1 min read

Q149.How do fixtures work with Page Object Model?

Fixtures can instantiate page objects and inject them into tests. This keeps tests clean and avoids repeatedly creating page object instances in every test file.

Medium Common 1 min read

Q150.Give an example of a custom fixture.

Example: ``ts import { test as base } from '@playwright/test'; import { LoginPage } from './pages/LoginPage'; export const test = base.extend<{ loginPage: LoginPage }>({ loginPage: async ({ page }, use) => { await use(new LoginPage(page)); } }); `` This provides LoginPage directly to tests.

Confidence check

If you can confidently answer the Fixtures, Hooks, and Test Runner 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.

7. Playwright API Testing and Network Handling

Easy Common 1 min read

Q151.What is APIRequestContext?

APIRequestContext is Playwright’s API client for making HTTP requests in tests. It supports GET, POST, PUT, PATCH, DELETE, headers, authentication, cookies, and response assertions. It is useful for API testing and test data setup. See the official Playwright API testing docs and our API testing interview questions for more practice.

Easy Common 1 min read

Q152.What is the request fixture?

The request fixture is a built-in Playwright fixture that provides APIRequestContext. It allows tests to call APIs without creating a browser page. This is useful for fast backend validations and hybrid UI/API tests.

Easy Common 1 min read

Q153.How do you send a GET request?

Use request.get(url). Example: const response = await request.get('/api/users'). Then assert response.ok(), status code, headers, or JSON body. GET requests are commonly used for validation.

Easy Common 1 min read

Q154.How do you send a POST request?

Use request.post(url, { data }). POST is commonly used to create resources, login through API, or prepare test data. Always assert status code and response body after creation.

Easy Common 1 min read

Q155.What is the difference between PUT and PATCH?

PUT usually replaces the entire resource, while PATCH updates specific fields. In tests, verify both status code and final resource state. Also validate idempotency and behavior when required fields are missing.

Easy Common 1 min read

Q156.How do you test DELETE APIs?

Send a DELETE request and verify the status code, response body, and that the resource no longer exists. Also test deleting an already deleted or unauthorized resource.

Easy Common 1 min read

Q157.How do you assert API responses in Playwright?

Use expect(response.status()).toBe(200), expect(response.ok()).toBeTruthy(), and validate JSON response fields. For schema validation, integrate libraries like Zod, Ajv, or custom validators.

Easy Common 1 min read

Q158.How do you handle authentication tokens in API tests?

Obtain the token through login API or CI secrets, then pass it in headers such as Authorization: Bearer token. Avoid hardcoding tokens. Refresh or regenerate tokens when they expire.

Easy Common 1 min read

Q159.What is a hybrid UI and API test?

A hybrid test uses APIs for setup or validation and UI for user-critical flows. For example, create a user through API, log in through UI, and verify dashboard behavior. This makes tests faster and more reliable.

Easy Common 1 min read

Q160.What is page.route?

page.route intercepts network requests matching a URL or pattern. It can mock responses, block requests, or modify outgoing requests. It is useful for testing edge cases without depending on real backend behavior.

Easy Common 1 min read

Q161.What is route.fulfill?

route.fulfill completes an intercepted request with a mocked response. You can return status, headers, body, or JSON. It is useful for testing empty states, error states, and predictable API responses.

Easy Common 1 min read

Q162.What is route.abort?

route.abort cancels an intercepted request. It is useful for simulating network failures, blocked resources, timeout scenarios, or unavailable third-party services.

Easy Common 1 min read

Q163.What is route.continue?

route.continue allows an intercepted request to continue to the server, optionally with modified headers, method, or post data. It is useful for adding test headers or modifying requests.

Easy Common 1 min read

Q164.How do you listen to request events?

Use page.on('request', callback). This helps inspect outgoing network requests, verify tracking calls, debug API calls, or ensure certain resources are requested.

Easy Common 1 min read

Q165.How do you listen to response events?

Use page.on('response', callback). This helps validate status codes, inspect API responses, or debug failed backend calls during UI tests.

Easy Common 1 min read

Q166.How do you mock APIs in Playwright?

Use page.route to intercept the API endpoint and route.fulfill with mock data. Mocking APIs makes tests deterministic and allows validation of rare states like server errors or empty results.

Easy Common 1 min read

Q167.What is HAR replay in Playwright?

HAR replay allows Playwright to serve network responses from a recorded HAR file. It can make tests more deterministic by replaying known backend responses. It is useful for demos, offline testing, and stable regression flows.

Easy Common 1 min read

Q168.Can Playwright test slow networks?

Yes. Playwright can simulate network behavior by routing requests, delaying responses, or using browser context options and CDP for Chromium-specific throttling. Testing slow networks helps validate loaders, retries, and timeout handling.

Easy Common 1 min read

Q169.How do you test API error states in UI?

Mock the API response using route.fulfill with status codes like 400, 401, 403, or 500. Then verify that the UI shows correct error messages, retry options, or fallback behavior.

Easy Common 1 min read

Q170.How do you test GraphQL with Playwright?

GraphQL requests usually go to one endpoint. Validate operationName, variables, response data, and errors. You can intercept GraphQL requests and return mocked responses for specific operations.

Easy Common 1 min read

Q171.What is contract-style validation?

Contract-style validation checks whether API responses follow expected structure, types, and required fields. It does not replace full contract testing tools, but it helps catch breaking API changes during UI or API automation.

Easy Common 1 min read

Q172.How do you test pagination APIs?

Verify page size, total count, next/previous tokens, sorting consistency, empty pages, invalid page numbers, and combined filters. For cursor pagination, verify that records do not duplicate or disappear across pages.

Easy Common 1 min read

Q173.How can APIs help with test setup?

APIs can create users, orders, products, permissions, or test records faster than UI steps. This keeps UI tests focused on user behavior instead of long setup flows.

Easy Common 1 min read

Q174.How can APIs help with cleanup?

APIs can delete test-created records after execution. Cleanup prevents test data pollution and reduces environment instability. Always design cleanup to be safe and idempotent.

Easy Common 1 min read

Q175.Can Playwright share cookies between UI and API tests?

Yes. APIRequestContext can share cookie storage with browser context depending on how it is created. This allows login through API and later validation through UI, or vice versa.

Easy Common 1 min read

Q176.How do you retry API assertions?

Use expect.poll or a custom retry loop when backend state is eventually consistent. Avoid blind waits. Retry meaningful conditions such as order status becoming completed.

Easy Common 1 min read

Q177.How do you configure API request timeout?

Timeouts can be passed in request options or configured globally. Proper API timeouts prevent tests from hanging and make failures easier to diagnose.

Easy Common 1 min read

Q178.How do you verify response headers?

Read headers using response.headers() and assert expected values such as content-type, cache-control, location, or security headers. Header validation is important for API correctness and security.

Easy Common 1 min read

Q179.How do you test security-related network behavior?

Validate authentication, authorization, secure headers, HTTPS usage, token handling, and blocked unauthorized requests. Playwright can inspect UI requests and API responses to detect security regressions.

Medium Common 1 min read

Q180.Give an example of API testing in Playwright.

Example: ``ts test('create user through API', async ({ request }) => { const response = await request.post('/api/users', { data: { name: 'QA User', email: 'qa@example.com' } }); expect(response.status()).toBe(201); const body = await response.json(); expect(body.email).toBe('qa@example.com'); }); `` This validates API creation directly.

Confidence check

If you can confidently answer the Playwright API Testing and Network Handling 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.

8. Authentication and Test Data Management

Easy Common 1 min read

Q181.How do you automate login in Playwright?

You can automate login through UI steps or API calls. For most large suites, login once using global setup and save storageState. This avoids repeated login and reduces execution time.

Easy Common 1 min read

Q182.How do you avoid repeated login in every test?

Use storageState. Login once, save authentication state to a JSON file, and configure tests to reuse it. This keeps tests faster and avoids failures caused by repeated login flow dependencies.

Easy Common 1 min read

Q183.What is storageState authentication?

storageState authentication means saving cookies and localStorage after login and reusing them in future tests. It is useful when tests need an already authenticated user session.

Easy Common 1 min read

Q184.How does global setup authentication work?

globalSetup runs before tests, logs in a user, saves storageState, and then tests use that saved state. This creates a clean and reusable authentication flow for CI and local execution.

Easy Common 1 min read

Q185.How do you test multiple user roles?

Create separate storageState files for each role, such as admin, manager, and viewer. Configure projects or fixtures to use the correct role. This supports role-based access testing.

Easy Common 1 min read

Q186.What is a good test data setup strategy?

A good strategy creates only the data needed for each test, uses unique identifiers, avoids shared mutable data, and cleans up after execution. API-based setup is often faster than UI-based setup.

Easy Common 1 min read

Q187.Why is test data cleanup important?

Cleanup prevents polluted environments, false failures, duplicate records, and unpredictable test results. Cleanup should be reliable, idempotent, and safe even if a test fails halfway.

Easy Common 1 min read

Q188.Why create test data using APIs?

API setup is faster and more stable than UI setup. It lets UI tests focus on the actual user journey being validated. For example, create an order through API and verify it in the UI.

Easy Common 1 min read

Q189.How do you manage database test data?

Use controlled seed data, test-specific records, transactions, or cleanup jobs. Direct database manipulation should be used carefully because it can bypass business rules. API setup is often safer.

Easy Common 1 min read

Q190.How do you create unique test data?

Use timestamps, UUIDs, worker indexes, or random suffixes. Unique test data prevents conflicts during parallel execution and avoids failures caused by duplicate emails, usernames, or order IDs.

Easy Common 1 min read

Q191.What is data-driven testing?

Data-driven testing runs the same test logic with different input values. In Playwright, data can come from arrays, JSON files, CSV files, or external sources. It improves coverage without duplicating test code.

Easy Common 1 min read

Q192.How do you use JSON test data?

Store data in JSON files and import it into tests. JSON is useful for structured test data such as users, products, roles, and expected messages. Keep sensitive data out of committed JSON files.

Easy Common 1 min read

Q193.How do you use CSV test data?

CSV can be parsed using Node.js libraries when tabular test data is needed. It is useful for large input combinations, but JSON is usually easier for nested data structures.

Easy Common 1 min read

Q194.How do you manage environment-specific test data?

Use environment variables and configuration files to separate dev, QA, staging, and production data. Avoid using production-sensitive data in automated tests unless tests are read-only and approved.

Easy Common 1 min read

Q195.How do you manage secrets in Playwright?

Use CI secret stores, environment variables, or secret management tools. Do not commit passwords, tokens, or API keys. Locally, use .env files excluded from version control.

Easy Common 1 min read

Q196.How do you handle OTP in automation?

Prefer test-only OTP bypasses, API access to retrieve OTP, static OTP in lower environments, or mocked authentication providers. Avoid relying on real SMS or email delivery in automated regression tests.

Easy Common 1 min read

Q197.How do you handle CAPTCHA in Playwright?

CAPTCHA should not be automated directly. Use test environment bypasses, feature flags, or mock verification services. CAPTCHA is designed to stop automation, so testing should focus on integration and fallback behavior.

Easy Common 1 min read

Q198.What are test data anti-patterns?

Anti-patterns include shared users for all tests, hardcoded data, no cleanup, dependency on production data, manual preconditions, and tests that must run in a specific order. These cause flaky and unreliable suites.

Easy Common 1 min read

Q199.What is seed data?

Seed data is predefined data loaded into an environment before tests. It is useful for reference values such as roles, categories, plans, and permissions. Seed data should be stable and version-controlled.

Easy Common 1 min read

Q200.How do you avoid data conflicts in parallel tests?

Use unique data per worker or test, avoid shared mutable records, and clean up created data. Playwright provides workerInfo, which can help generate worker-specific users or data identifiers. CTA after Q200: Ready to practice these Playwright answers in a real interview format? Try AI Mock Interview → /ai-mock-interview Start Free → /login

Easy Common 1 min read

Q201.How do you handle expired authentication state?

If storageState expires, regenerate it in global setup. Tests should not rely on old authentication files forever. In CI, create fresh storage state for each run to avoid token expiry failures.

Easy Common 1 min read

Q202.How do you design role-based access tests?

Define expected permissions for each role and validate allowed and blocked actions. Use separate users or storageState files for each role. Test both UI visibility and backend authorization where possible.

Easy Common 1 min read

Q203.How do you test negative authentication scenarios?

Test invalid password, locked account, expired token, missing token, wrong role, and direct URL access without login. Negative authentication tests should verify both error messages and blocked access.

Easy Common 1 min read

Q204.What if cleanup fails after a test?

Cleanup should be retried or handled by scheduled cleanup jobs using unique test identifiers. Tests should log created data to make manual cleanup easier. Cleanup failure should be visible, not silently ignored.

Medium Common 1 min read

Q205.Give an example of storageState setup.

Example: ``ts const browser = await chromium.launch(); const page = await browser.newPage(); await page.goto('/login'); await page.getByLabel('Email').fill(process.env.USER_EMAIL!); await page.getByLabel('Password').fill(process.env.USER_PASSWORD!); await page.getByRole('button', { name: 'Login' }).click(); await page.context().storageState({ path: 'auth/user.json' }); await browser.close(); `` Tests can reuse auth/user.json.

Confidence check

If you can confidently answer the Authentication and Test Data Management 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.

9. Debugging, Tracing, Screenshots, Videos, and Reports

Easy Common 1 min read

Q206.What is Playwright Inspector?

Playwright Inspector is a debugging tool that lets you step through tests, inspect locators, view actions, and pause execution. It is useful for developing and fixing tests locally.

Easy Common 1 min read

Q207.What is PWDEBUG?

PWDEBUG is an environment variable used to run Playwright in debug mode. Example: PWDEBUG=1 npx playwright test. It opens the inspector and runs tests in headed mode with slower execution.

Easy Common 1 min read

Q208.What is Playwright codegen?

Codegen records user actions and generates Playwright test code. It is useful for learning selectors and quickly creating draft tests. However, generated code should be reviewed and refactored before production use.

Easy Common 1 min read

Q209.What is Trace Viewer?

Trace Viewer is a Playwright tool for analyzing test execution. It shows actions, screenshots, DOM snapshots, console logs, network calls, and errors. It is one of the best tools for debugging CI failures.

Easy Common 1 min read

Q210.How do you enable traces?

Traces can be enabled in config using trace: 'on', 'retain-on-failure', or 'on-first-retry'. A common CI setting is trace: 'on-first-retry' because it captures useful data without storing traces for every passed test.

Easy Common 1 min read

Q211.How do you capture screenshots?

Use page.screenshot() manually or configure screenshot: 'only-on-failure'. Screenshots help understand UI state at failure time and are useful in reports.

Easy Common 1 min read

Q212.How do you record videos?

Videos can be enabled using video: 'on', 'retain-on-failure', or 'off'. Video recording is useful for debugging complex UI flows but can increase storage usage in CI.

Easy Common 1 min read

Q213.How do you capture console logs?

Use page.on('console', msg => console.log(msg.text())). Console logs help debug frontend errors, warnings, and application logs during test execution.

Easy Common 1 min read

Q214.How do you capture page errors?

Use page.on('pageerror', error => ...). Page errors indicate uncaught JavaScript exceptions. Capturing them helps detect frontend issues even if the UI appears normal.

Easy Common 1 min read

Q215.What are test artifacts?

Artifacts are files generated during tests, such as screenshots, videos, traces, logs, and reports. They help investigate failures, especially in CI environments where the browser is not visible.

Easy Common 1 min read

Q216.What is the HTML reporter?

The HTML reporter generates an interactive report showing passed, failed, skipped, and flaky tests. It includes test steps, errors, screenshots, videos, and traces when configured.

Easy Common 1 min read

Q217.What is the JSON reporter?

The JSON reporter outputs test results in machine-readable format. It is useful for dashboards, custom reporting, analytics, and integration with internal tools.

Easy Common 1 min read

Q218.What is the JUnit reporter?

The JUnit reporter creates XML output compatible with CI tools such as Jenkins, GitLab CI, Azure DevOps, and test reporting plugins. It is commonly used in enterprise pipelines.

Easy Common 1 min read

Q219.Can Playwright integrate with Allure?

Yes. Playwright can integrate with Allure using third-party reporters. Allure provides rich reports, history, categories, attachments, and trend analysis for larger QA teams.

Easy Common 1 min read

Q220.How do you upload artifacts in CI?

Configure CI to upload playwright-report, test-results, screenshots, videos, and traces as build artifacts. This allows developers to debug failures after the pipeline finishes.

Easy Common 1 min read

Q221.How do you debug flaky tests?

Analyze traces, screenshots, videos, retries, network logs, and test data. Look for weak locators, race conditions, shared state, slow APIs, or environment instability. Fix the root cause instead of increasing timeouts blindly.

Easy Common 1 min read

Q222.What is time-travel debugging?

Time-travel debugging means inspecting each step of a test using Trace Viewer. You can see what the page looked like before and after actions, which network calls happened, and why an assertion failed.

Easy Common 1 min read

Q223.How do you investigate slow tests?

Use reports and traces to identify slow steps, repeated login, unnecessary waits, heavy setup, or slow backend responses. Optimize by using API setup, storageState, parallel execution, and focused assertions.

Easy Common 1 min read

Q224.What is good failure analysis?

Good failure analysis identifies whether the issue is test code, application bug, data problem, environment issue, or network dependency. Attach traces and logs so developers can reproduce and fix failures quickly.

Easy Occasional 1 min read

Q225.How do you debug locator strictness errors?

Check how many elements the locator matches using count() or inspect it in the trace viewer. Improve the locator by adding role name, filtering by text, or narrowing scope with parent locators.

Easy Occasional 1 min read

Q226.How do you debug network failures?

Use page.on('requestfailed'), response logs, trace viewer network tab, and waitForResponse. Validate status codes, payloads, authentication headers, and environment availability.

Easy Occasional 1 min read

Q227.Can Playwright do screenshot comparisons?

Yes. Playwright supports visual comparisons using expect(page).toHaveScreenshot(). This is useful for visual regression testing, but baselines must be managed carefully across browsers and operating systems.

Easy Occasional 1 min read

Q228.Why use trace on first retry?

Trace on first retry captures diagnostic information only when a test fails and retries. It keeps CI storage lower than tracing every test while still providing useful debugging data for flaky failures.

Easy Occasional 1 min read

Q229.How do you debug local versus CI failures?

Compare browser version, OS, viewport, environment variables, baseURL, test data, timezone, locale, and resource speed. CI often exposes race conditions because it runs slower or more parallel than local machines.

Medium Occasional 1 min read

Q230.Give an example of debugging configuration.

Example: ``ts use: { screenshot: 'only-on-failure', video: 'retain-on-failure', trace: 'on-first-retry' }, reporter: [['html'], ['junit', { outputFile: 'results.xml' }]] `` This configuration captures useful failure artifacts.

Confidence check

If you can confidently answer the Debugging, Tracing, Screenshots, Videos, and Reports 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.

10. Playwright Framework Design and Page Object Model

Easy Occasional 1 min read

Q231.What is a good Playwright framework structure?

A good structure separates tests, pages, fixtures, test data, utilities, API clients, configuration, and reports. This improves maintainability and helps teams scale automation without duplicating code.

Easy Occasional 1 min read

Q232.What is Page Object Model?

Page Object Model is a design pattern where page-specific locators and actions are stored in separate classes. Tests call meaningful methods like login() or addProductToCart() instead of directly handling every selector.

Easy Occasional 1 min read

Q233.What are the benefits of POM?

POM improves readability, reusability, maintainability, and abstraction. If a locator changes, it is updated in one page class instead of many tests. It also makes test scenarios easier to understand.

Easy Occasional 1 min read

Q234.Where should locators be stored in POM?

Locators should be stored inside the page object class as readonly locator properties or methods. This keeps UI implementation details away from tests and makes maintenance easier.

Easy Occasional 1 min read

Q235.How do fixtures improve POM?

Fixtures can create and inject page objects into tests automatically. This avoids repetitive initialization and gives every test a clean, consistent object setup.

Easy Occasional 1 min read

Q236.What are component objects?

Component objects represent reusable UI components such as navigation bars, modals, tables, date pickers, or product cards. They reduce duplication when the same component appears on multiple pages.

Easy Occasional 1 min read

Q237.What is a service or API layer?

A service layer contains reusable API methods for setup, cleanup, and backend validation. It keeps API logic separate from UI tests and supports hybrid automation strategies.

Easy Occasional 1 min read

Q238.What is a base page?

A base page contains shared page behavior such as navigation helpers, common waits, screenshot helpers, or shared components. Avoid putting too much logic in the base page because it can become a dumping ground.

Easy Occasional 1 min read

Q239.What utilities are useful in a Playwright framework?

Useful utilities include data generators, date helpers, file helpers, API clients, environment readers, custom assertions, test data builders, and logging helpers. Utilities should be small and focused.

Easy Occasional 1 min read

Q240.What are reusable assertions?

Reusable assertions are helper methods for common validations, such as verifying toast messages, table rows, or page headers. They reduce duplication and improve consistency across tests.

Easy Occasional 1 min read

Q241.Should Playwright have custom commands like Cypress?

Playwright does not use custom commands in the same way as Cypress. Instead, use fixtures, helper functions, page objects, and custom expect matchers when needed.

Easy Occasional 1 min read

Q242.What are test data builders?

Test data builders create test objects with sensible defaults and allow overriding specific fields. They make tests cleaner and reduce repeated data setup code.

Easy Occasional 1 min read

Q243.What should a reporting layer include?

A reporting layer should include HTML reports, CI reports, screenshots, traces, videos, logs, and test metadata. For large teams, Allure or dashboard integrations may be useful.

Easy Occasional 1 min read

Q244.How should configuration be designed?

Configuration should separate common settings from environment-specific values. Use baseURL, projects, environment variables, and CI overrides. Avoid hardcoding URLs, credentials, or browser settings inside tests.

Easy Occasional 1 min read

Q245.How do you manage environments in a framework?

Use environment variables such as BASE_URL, USER_EMAIL, and API_URL. Optionally use config files for dev, QA, staging, and production. The same tests should run across environments with minimal changes.

Easy Occasional 1 min read

Q246.How do you make a framework scalable?

Design independent tests, reusable fixtures, stable locators, API setup, parallel execution, clear folders, tagging, reporting, and CI integration. Scalability depends on both technical design and team discipline.

Easy Occasional 1 min read

Q247.How do you make tests maintainable?

Use readable test names, stable locators, POM or screen objects, reusable helpers, limited duplication, good code reviews, and meaningful assertions. Avoid hiding too much logic inside large helper methods.

Easy Occasional 1 min read

Q248.What should be checked in Playwright code reviews?

Review locator quality, test independence, assertion strength, data setup, cleanup, hard waits, readability, unnecessary retries, and whether the test validates real business value.

Easy Occasional 1 min read

Q249.What is overengineering in automation frameworks?

Overengineering means adding unnecessary abstraction, complex inheritance, generic wrappers, or framework code that makes tests harder to read. A good framework should simplify testing, not become harder than the product.

Easy Occasional 1 min read

Q250.Why are naming conventions important?

Consistent names for tests, page objects, fixtures, and data files help teams understand and maintain the framework. Good naming reduces onboarding time and prevents confusion.

Easy Occasional 1 min read

Q251.Should assertions be inside page objects?

Basic UI state checks can be inside page objects, but business assertions are often clearer in tests. Avoid hiding all expectations inside page methods because tests should clearly show what is being verified.

Easy Occasional 1 min read

Q252.Should selectors be centralized globally?

Not usually. Selectors should be close to the page or component they belong to. A giant global selector file becomes hard to maintain and does not scale well.

Easy Occasional 1 min read

Q253.How should errors be handled in a framework?

Let Playwright assertions fail naturally with clear messages. Add custom error messages only where they improve debugging. Avoid catching errors and hiding failures unless cleanup or logging is required.

Easy Occasional 1 min read

Q254.How do you onboard new team members to a Playwright framework?

Provide setup instructions, folder structure, coding standards, locator strategy, test data rules, sample tests, and CI instructions. A strong README and example test help new members become productive quickly.

Medium Occasional 1 min read

Q255.Give an example of a Page Object Model class.

Example: ``ts export class LoginPage { constructor(private page: Page) {} email = this.page.getByLabel('Email'); password = this.page.getByLabel('Password'); loginButton = this.page.getByRole('button', { name: 'Login' }); async login(email: string, password: string) { await this.email.fill(email); await this.password.fill(password); await this.loginButton.click(); } } `` This keeps login logic reusable.

Confidence check

If you can confidently answer the Playwright Framework Design and Page Object Model 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.

11. CI/CD, Docker, Parallel Execution, and Cloud Grid

Easy Occasional 1 min read

Q256.How do you run Playwright in GitHub Actions?

Install dependencies, install browsers, run npx playwright test, and upload reports as artifacts. Playwright provides good CI documentation and works well with GitHub-hosted runners.

Easy Occasional 1 min read

Q257.How do you run Playwright in Jenkins?

Create a pipeline that checks out code, installs Node dependencies, installs Playwright browsers, runs tests, and publishes HTML or JUnit reports. Store credentials in Jenkins credentials, not code.

Easy Occasional 1 min read

Q258.How do you run Playwright in Azure DevOps?

Use a YAML pipeline with Node setup, npm ci, npx playwright install --with-deps, and npx playwright test. Publish test results and artifacts using Azure DevOps publishing tasks.

Easy Occasional 1 min read

Q259.How do you run Playwright in GitLab CI?

Use a GitLab CI YAML file with a Playwright Docker image or Node image. Install dependencies, run tests, and save reports, traces, and screenshots as artifacts.

Easy Occasional 1 min read

Q260.Why use Docker for Playwright?

Docker provides a consistent runtime environment with browsers, dependencies, and OS libraries. It reduces “works on my machine” problems and makes CI execution more predictable.

Easy Occasional 1 min read

Q261.What are Playwright Docker images?

Playwright provides official Docker images containing browsers and required system dependencies. They simplify CI setup and avoid dependency issues on Linux agents.

Easy Occasional 1 min read

Q262.Why is browser installation important in CI?

Playwright browsers must be installed before tests run. In Linux CI, system dependencies may also be required. Using npx playwright install --with-deps or official Docker images solves this.

Easy Occasional 1 min read

Q263.What should be cached in CI?

Cache npm dependencies where appropriate, but be careful with browser cache compatibility. Many teams use npm ci for clean reproducible installs. Browser caching can speed pipelines but must be managed carefully.

Easy Occasional 1 min read

Q264.Should retries be enabled in CI?

Yes, limited retries such as 1 or 2 are common in CI. However, retries should not hide flaky tests. Use traces and dashboards to track tests that pass only after retry.

Easy Occasional 1 min read

Q265.How do workers affect CI execution?

Workers control parallelism. More workers can reduce runtime, but too many can overload the application under test or CI machine. Tune workers based on CPU, memory, and environment capacity.

Easy Occasional 1 min read

Q266.What is sharding in CI?

Sharding splits tests across multiple CI jobs. For example, four jobs can each run one-fourth of the suite. This is useful for large regression suites where one machine would take too long.

Easy Occasional 1 min read

Q267.What is test splitting?

Test splitting divides tests by files, tags, historical duration, or shards. It helps balance workload across CI jobs and reduce total pipeline time.

Easy Occasional 1 min read

Q268.What is flaky test quarantine?

Quarantine means separating unstable tests from blocking pipelines while they are investigated. It prevents unreliable tests from stopping releases but should be temporary and tracked.

Easy Occasional 1 min read

Q269.Can Playwright run on BrowserStack?

Yes. Playwright can run on BrowserStack for cloud browser testing. This helps validate real browser and platform combinations beyond local or CI-provided browsers.

Easy Occasional 1 min read

Q270.Can Playwright run on Sauce Labs or LambdaTest?

Yes. Cloud testing providers such as Sauce Labs and LambdaTest support Playwright execution. They are useful for cross-platform coverage, browser versions, and enterprise reporting needs.

Easy Occasional 1 min read

Q271.What artifacts should be uploaded in CI?

Upload HTML reports, JUnit XML, traces, screenshots, videos, and logs. These artifacts help debug failures without rerunning tests locally.

Easy Occasional 1 min read

Q272.How do you optimize Playwright pipelines?

Use API setup, storageState authentication, parallel workers, sharding, selective tags, test impact analysis, efficient locators, and reduced unnecessary waits. Keep smoke tests fast and regression tests scalable.

Easy Occasional 1 min read

Q273.How do you manage secrets in CI?

Use CI secret storage such as GitHub Secrets, Jenkins Credentials, GitLab Variables, or Azure Key Vault. Never print secrets in logs or commit them to repositories.

Easy Occasional 1 min read

Q274.What is fail-fast strategy?

Fail-fast stops execution early when critical failures occur. It is useful for smoke pipelines but less useful for full regression where teams want complete failure visibility.

Medium Occasional 1 min read

Q275.Give an example GitHub Actions workflow.

Example: ``yaml name: Playwright Tests on: [push, pull_request] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 - run: npm ci - run: npx playwright install --with-deps - run: npx playwright test - uses: actions/upload-artifact@v4 if: always() with: name: playwright-report path: playwright-report/ `` This runs tests and uploads reports.

Confidence check

If you can confidently answer the CI/CD, Docker, Parallel Execution, and Cloud Grid 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.

12. Advanced, Scenario-Based, and Senior-Level Playwright Questions

Medium Occasional 1 min read

Q276.How would you design a Playwright framework from scratch?

Start with clear folder structure, Playwright config, TypeScript, fixtures, page objects, API clients, data builders, reporting, and CI integration. Prioritize test isolation, stable locators, storageState authentication, and parallel execution from the beginning. For a complete implementation, follow our Playwright framework setup with TypeScript guide.

Easy Occasional 1 min read

Q277.How would you migrate from Selenium to Playwright?

Do not blindly convert every Selenium test. First identify high-value stable flows, design a Playwright framework, migrate smoke tests, compare execution time and flakiness, then gradually migrate regression coverage. Keep Selenium running during transition if needed.

Easy Occasional 1 min read

Q278.What are risks in Selenium to Playwright migration?

Risks include rewriting too many tests at once, copying bad locator strategies, ignoring framework design, underestimating training needs, and losing historical coverage. A phased migration with clear priorities works best.

Easy Occasional 1 min read

Q279.How do you test micro-frontend applications?

Test critical user journeys across micro-frontends, validate integration points, mock unstable services when needed, and use contract tests for boundaries. Avoid tying tests to internal implementation of each micro-frontend.

Easy Occasional 1 min read

Q280.How do you test highly dynamic applications?

Use stable user-facing locators, wait for meaningful business states, validate API responses when needed, and avoid hard waits. Dynamic apps require strong test data control and clear synchronization points.

Easy Occasional 1 min read

Q281.How do you test role-based access control?

Create users for each role, verify visible and hidden UI actions, test direct URL access, and validate backend authorization through APIs. Do not rely only on UI visibility because security must be enforced server-side.

Easy Occasional 1 min read

Q282.How do you test third-party integrations?

Mock third-party services for most automated tests and keep a small number of integration tests against sandbox environments. This balances reliability, cost, and confidence.

Easy Occasional 1 min read

Q283.How do you avoid brittle tests?

Use stable locators, avoid layout-based selectors, keep tests independent, use API setup, write clear assertions, avoid excessive abstraction, and review tests like production code.

Easy Occasional 1 min read

Q284.How would you improve a flaky Playwright suite?

Collect failure data, identify top flaky tests, inspect traces, fix locator and data issues, remove hard waits, isolate shared state, improve environment stability, and track retry-based passes. Fixing flakiness should be systematic.

Easy Occasional 1 min read

Q285.How do you choose the best locator?

Prefer getByRole, getByLabel, and getByText for user-facing elements. Use getByTestId for complex or unstable UI. Avoid long XPath and CSS tied to styling. A good locator is readable and resilient.

Easy Occasional 1 min read

Q286.How do you debug production-only failures?

Compare environment data, feature flags, browser versions, permissions, network responses, third-party services, and user roles. Use traces, logs, and safe read-only tests. Avoid destructive automation in production.

Easy Occasional 1 min read

Q287.What is the test pyramid?

The test pyramid recommends many unit tests, fewer API/integration tests, and fewer UI end-to-end tests. Playwright is powerful for UI and API tests, but not every scenario should be automated through the UI.

Easy Occasional 1 min read

Q288.How do you balance API and UI automation?

Use API tests for business rules, data validation, and fast coverage. Use UI tests for critical user journeys and visual workflow validation. Combine both for efficient and reliable automation.

Easy Occasional 1 min read

Q289.How do you track flaky tests over time?

Use CI history, retry data, failure categories, dashboards, and test annotations. Track whether failures are due to product bugs, environment issues, test data, or automation code. Prioritize the most frequent blockers.

Easy Occasional 1 min read

Q290.How do you manage Playwright tests in a monorepo?

Keep shared utilities in common packages, define project-specific configs, use tags or paths for selective execution, and avoid cross-team coupling. CI should run only impacted tests where possible.

Easy Occasional 1 min read

Q291.How do you approach visual testing with Playwright?

Use screenshot comparisons for stable UI components and critical pages. Control fonts, viewport, browser, animations, and data. Visual testing is valuable but requires careful baseline management to avoid noisy failures.

Easy Occasional 1 min read

Q292.Can Playwright help with accessibility testing?

Yes. Playwright can validate keyboard navigation, ARIA roles, labels, focus behavior, and integrate with tools like axe-core. Accessibility-first locators also encourage better accessible UI design.

Easy Occasional 1 min read

Q293.How do you handle test data in parallel senior-level frameworks?

Use worker-specific users, unique identifiers, API setup, isolated records, and cleanup strategies. Avoid shared mutable data. Parallel-safe test data is essential for fast and reliable enterprise automation.

Easy Occasional 1 min read

Q294.How does contract testing relate to Playwright?

Playwright can validate API response shapes, but dedicated contract testing tools are better for formal consumer-provider contracts. Use Playwright for UI/API confidence and contract tests for service compatibility.

Easy Occasional 1 min read

Q295.How do you test mobile behavior with Playwright?

Use device emulation for viewport, user agent, touch, and mobile layout validation. For real mobile browser behavior, complement emulation with device cloud testing when required.

Easy Occasional 1 min read

Q296.How do you consider performance in Playwright tests?

Avoid unnecessary UI setup, hard waits, repeated login, and oversized scenarios. Use API setup, parallel execution, storageState, and focused assertions. Tests should be fast enough to provide feedback in CI.

Easy Occasional 1 min read

Q297.How do you define team standards for Playwright?

Create standards for locator strategy, folder structure, naming, test data, assertions, tagging, code review, CI artifacts, and flaky test handling. Document them and enforce through reviews and examples.

Easy Occasional 1 min read

Q298.How do you measure automation ROI?

Measure reduced manual regression time, faster release feedback, defect detection, pipeline stability, test maintenance effort, and confidence in critical flows. ROI is not just number of tests; it is useful feedback.

Easy Occasional 1 min read

Q299.What should a senior SDET emphasize in a Playwright interview?

A senior SDET should discuss framework design, test strategy, CI/CD, parallel execution, flakiness management, API/UI balance, maintainability, team standards, and business risk coverage. Senior answers should explain trade-offs, not just syntax.

Medium Occasional 1 min read

Q300.What roadmap would you suggest for adopting Playwright in a team?

Start with training and proof of concept, automate critical smoke flows, design framework standards, integrate CI, add API setup, migrate high-value tests, monitor flakiness, and expand regression coverage gradually. Adoption should be practical, measurable, and team-friendly. For a production-ready blueprint, see our Playwright framework setup with TypeScript guide.

Confidence check

If you can confidently answer the Advanced, Scenario-Based, and Senior-Level Playwright Questions 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: What is Playwright — Playwright is an open-source browser automation framework developed by Microsoft .
  2. Q2: Why is Playwright used in automation testing — Playwright is used to automate browser-based testing for modern web applications.
  3. Q3: Which browsers does Playwright support — Playwright supports Chromium, Firefox, and WebKit browser engines.
  4. Q4: Which programming languages are supported by Playwright — Playwright supports TypeScript, JavaScript, Python, Java, and .NET.
  5. Q5: What is Playwright Test — Playwright Test is the official test runner provided by Playwright.

Frequently asked questions

Yes. Playwright is a good tool for freshers because it has clean syntax, strong documentation, and modern automation features. Freshers should learn basic TypeScript or JavaScript, locators, assertions, auto-waiting, and simple test structure.

Playwright is often better for new modern web automation projects because it has auto-waiting, tracing, network mocking, and easier setup. Selenium is still valuable for legacy frameworks and wide ecosystem support.

TypeScript is the best choice for most Playwright interviews because Playwright Test is very strong in the Node.js ecosystem. However, Python, Java, and .NET are also supported.

For basics, 7 to 10 days may be enough. For experienced SDET interviews, 3 to 4 weeks of practice is better because framework design, CI/CD, API testing, and debugging are also asked.

TypeScript is highly recommended, especially for SDET roles. You do not need advanced TypeScript, but you should understand async/await, types, imports, classes, and basic project structure.

The most asked topics are locators, auto-waiting, assertions, browser contexts, fixtures, storageState authentication, API testing, network mocking, tracing, CI/CD, and Playwright vs Selenium.

Yes. Playwright includes APIRequestContext and the request fixture for API testing. It can test REST APIs, create test data, validate responses, and combine API setup with UI tests.

Practice by writing real tests, explaining why you use locators and auto-waiting, debugging failures with traces, and doing mock interviews. Use SoftwareTestPilot’s AI Mock Interview to rehearse answers in an interview format.

Was this article helpful?

Cluster · QA Career

More from QA Interview Questions

Behavioral, framework, coding — full interview prep.

Pillar guide · 10 articles
More in this cluster
From the QA Career pillar

Key takeaways

  • Master the fundamentals before tackling advanced Playwright scenarios.
  • Always explain trade-offs — interviewers reward judgement, not memorisation.
  • Use real project examples; generic answers blend in.
  • Practice answers out loud — written prep doesn't transfer to live rounds.
  • Revise the 30-second cheat sheet the night before your interview.
  • Keep one strong scenario story ready for every section above.

These Questions Are Just the Start

Get 1000+ more with detailed model answers in our QA Interview Preparation Kit. Covers manual testing, automation, API, SQL, Selenium, Playwright, and framework concepts — everything asked in real QA interviews.

Get Interview Kit — ₹1,045

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