Introduction: How to Prepare for Playwright Interviews in 2026
If you are preparing for a QA Automation Engineer, SDET, or automation architect interview, this top 50 Playwright interview questions guide covers the concepts most likely to matter in practical interviews.
Playwright has become an important browser automation framework for modern web applications. Its capabilities include resilient locators, automatic actionability checks, browser contexts, test fixtures, authentication state reuse, network interception, parallel execution, tracing, and cross-browser projects.
However, interviewers rarely focus only on syntax.
They want to know whether you can:
- Design maintainable automation.
- Choose reliable locators.
- Explain Playwright architecture.
- Debug flaky tests.
- Build a Page Object Model.
- Handle authentication and test data.
- Run tests in CI/CD.
- Scale tests using parallelism and sharding.
- Test APIs and mock network responses.
- Make good framework decisions.
This Top Playwright Interview Questions guide is therefore organized from fundamentals to advanced, scenario-based questions.
How to Use This Top 50 Playwright Interview Questions Guide
Use the questions according to your experience level.
| Experience | Priority |
| Fresher | Questions 1–20 |
| 2–3 years | Questions 11–35 |
| 4–5 years | Questions 21–45 |
| Senior SDET | Questions 31–50 |
| QA Lead | Architecture, CI/CD, scalability, migration, reliability |
For every question, focus on five things:
Question → Short Interview Answer → Detailed Explanation → Code Example → Interview Tip
Do not memorize the answers word for word. Understand the reasoning behind them.
Top 50 Playwright Interview Questions and Answers
Questions 1–10: Playwright Fundamentals
1. What is Playwright?
Difficulty: Beginner
Question: What is Playwright?
Short Interview Answer:
Playwright is an end-to-end browser automation framework developed by Microsoft. It supports Chromium, Firefox, and WebKit and provides APIs for browser automation and testing.
Detailed Explanation:
Playwright supports JavaScript/TypeScript, Python, Java, and .NET. Its Node.js ecosystem includes Playwright Test, which provides fixtures, assertions, parallel execution, projects, retries, and reporting.
It is designed for modern web applications and provides features such as auto-waiting, browser isolation, network interception, and tracing.
Code Example:
import { test, expect } from ‘@playwright/test’;
test(‘home page’, async ({ page }) => {
await page.goto(‘https://example.com’);
await expect(page).toHaveTitle(/Example/);
});
Interview Tip:
Do not describe Playwright as “just another Selenium alternative.” Explain its automation and testing capabilities.
2. What browsers does Playwright support?
Difficulty: Beginner
Question: Which browsers can Playwright automate?
Short Interview Answer:
Playwright supports Chromium, Firefox, and WebKit, along with branded browsers such as Google Chrome and Microsoft Edge. It also supports configured device emulation.
Detailed Explanation:
You can define multiple browser projects in playwright.config.ts.
Code Example:
projects: [
{ name: ‘chromium’, use: { browserName: ‘chromium’ } },
{ name: ‘firefox’, use: { browserName: ‘firefox’ } },
{ name: ‘webkit’, use: { browserName: ‘webkit’ } }
]
Interview Tip:
Mention that Playwright’s WebKit support is particularly useful when validating Safari-like browser behavior.
3. What is the difference between Browser, BrowserContext, and Page?
Difficulty: Beginner
Question: Explain Browser, BrowserContext, and Page.
Short Interview Answer:
Browser represents the browser process, BrowserContext represents an isolated browser session, and Page represents a tab or popup inside a context.
Detailed Explanation:
Browser
├── BrowserContext
│ ├── Page
│ └── Page
└── BrowserContext
└── Page
Contexts isolate cookies, storage, and session information.
Code Example:
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto(‘https://example.com’);
await context.close();
await browser.close();
Interview Tip:
BrowserContext is one of the most important concepts for Selenium engineers transitioning to Playwright.
4. What is a Page in Playwright?
Difficulty: Beginner
Question: What does the Page object represent?
Short Interview Answer:
A Page represents a single tab or popup within a browser context. It provides APIs for navigation, interaction, assertions, screenshots, dialogs, and page events.
Code Example:
await page.goto(‘/login’);
await page.getByLabel(‘Email’).fill(‘user@example.com’);
await page.screenshot({ path: ‘login.png’ });
Interview Tip:
A context can contain multiple pages, so do not describe Page as the browser itself.
5. What are the main advantages of Playwright?
Difficulty: Beginner
Question: Why is Playwright popular for automation?
Short Interview Answer:
Important advantages include resilient locators, automatic actionability waiting, browser isolation, cross-browser testing, network interception, parallel execution, tracing, and integrated Playwright Test features.
Detailed Explanation:
It is particularly useful for dynamic applications where elements are frequently rendered or updated.
Interview Tip:
Avoid saying Playwright is universally better than Selenium. Discuss project-specific trade-offs.
6. What is Playwright Test?
Difficulty: Beginner
Question: What is Playwright Test?
Short Interview Answer:
Playwright Test is Playwright’s test runner for Node.js/TypeScript. It provides fixtures, assertions, test isolation, projects, retries, parallel execution, reporting, and configuration.
Code Example:
import { test, expect } from ‘@playwright/test’;
test(‘login’, async ({ page }) => {
await page.goto(‘/login’);
await expect(page).toHaveURL(/login/);
});
Interview Tip:
Separate the Playwright browser automation library from the Playwright Test runner concept.
7. How do you install Playwright?
Difficulty: Beginner
Question: How do you install Playwright?
Short Interview Answer:
npm init playwright@latest
For existing projects:
npm install -D @playwright/test
Playwright browser binaries are version-specific, so browser installation may need to be repeated after Playwright updates.
Interview Tip:
Know the difference between installing the npm package and installing browser binaries.
8. What is playwright.config.ts?
Difficulty: Beginner
Question: Why is the Playwright configuration file important?
Short Interview Answer:
It centralizes framework settings such as browsers, base URL, timeouts, retries, workers, reporters, screenshots, videos, traces, and projects.
Code Example:
import { defineConfig } from ‘@playwright/test’;
export default defineConfig({
testDir: ‘./tests’,
timeout: 30_000,
use: {
baseURL: ‘https://staging.example.com’,
screenshot: ‘only-on-failure’
}
});
Interview Tip:
A strong framework keeps environment and execution configuration out of individual tests.
9. What is test isolation in Playwright?
Difficulty: Intermediate
Question: How does Playwright isolate tests?
Short Interview Answer:
Playwright Test creates isolated browser contexts for tests, giving tests separate cookies, storage, and session state. This reduces failure carry-over between tests.
Code Example:
test(‘test A’, async ({ page }) => {
// isolated context
});
test(‘test B’, async ({ page }) => {
// another isolated context
});
Interview Tip:
Connect isolation to parallel execution and flaky-test prevention.
10. What is the difference between Playwright and Selenium?
Difficulty: Beginner
Question: How does Playwright differ from Selenium?
Short Interview Answer:
Selenium is based around the WebDriver ecosystem, while Playwright provides its own browser automation model with BrowserContexts, locators, actionability waiting, and an integrated test runner.
Comparison:
| Area | Playwright | Selenium |
| Test runner | Playwright Test | External runners commonly used |
| Isolation | BrowserContext | WebDriver sessions |
| Locator model | Strong semantic locators | WebDriver locator strategies |
| Waiting | Built-in actionability | Explicit/implicit waits |
| Network mocking | Built in | Ecosystem/BiDi options |
| Parallelism | Built into Playwright Test | Grid/test-runner ecosystem |
Interview Tip:
Explain differences objectively rather than declaring one framework universally superior.
Questions 11–20: Locators, Assertions, and Synchronization
11. What are Playwright locators?
Difficulty: Beginner
Question: What is a locator?
Short Interview Answer:
A locator identifies elements on a page and provides Playwright’s auto-waiting and retry behavior. Recommended locators include roles, labels, text, placeholders, and test IDs.
Code Example:
await page.getByRole(‘button’, { name: ‘Login’ }).click();
await page.getByLabel(‘Username’).fill(‘john’);
Interview Tip:
Explain locator strategy, not just syntax.
12. What is strict mode?
Difficulty: Intermediate
Question: What happens when an action locator matches multiple elements?
Short Interview Answer:
Playwright actions generally require a unique target. If multiple elements match, a strictness violation can occur.
Code Example:
await page.getByRole(‘button’, { name: ‘Delete’ }).click();
If there are several Delete buttons, narrow the locator:
const row = page.getByRole(‘row’).filter({
hasText: ‘John’
});
await row.getByRole(‘button’, { name: ‘Delete’ }).click();
Interview Tip:
Do not immediately solve strictness issues with .first() or .nth(). First improve uniqueness.
13. What is auto-waiting?
Difficulty: Intermediate
Question: How does Playwright wait before clicking an element?
Short Interview Answer:
Playwright checks actionability conditions such as uniqueness, visibility, stability, event reception, and enabled state before performing supported actions.
Code Example:
await page.getByRole(‘button’, { name: ‘Submit’ }).click();
Interview Tip:
Never say “Playwright waits for everything.” Explain actionability.
14. What are web-first assertions?
Difficulty: Intermediate
Question: Why use expect() instead of immediately reading a value?
Short Interview Answer:
Playwright assertions automatically retry until the expected condition is met or the timeout is reached.
Code Example:
await expect(page.getByText(‘Success’)).toBeVisible();
await expect(page).toHaveURL(/dashboard/);
Interview Tip:
Assertions are also synchronization points.
15. How do you handle dynamic elements?
Difficulty: Intermediate
Question: An ID changes after every refresh. What do you do?
Short Interview Answer:
Avoid the dynamic ID and use a stable semantic attribute, label, role, text, or test ID.
Code Example:
await page.getByLabel(‘Username’).fill(‘john’);
instead of:
await page.locator(‘#input-839281’).fill(‘john’);
Interview Tip:
Mention that locator resilience is more important than selector brevity.
16. How do you handle iframes?
Difficulty: Intermediate
Question: How do you locate an element inside an iframe?
Short Interview Answer:
Use frameLocator() to enter the iframe context.
Code Example:
const payment = page.frameLocator(‘#payment-frame’);
await payment.getByLabel(‘Card Number’).fill(‘4111111111111111’);
Interview Tip:
Do not try to locate iframe content directly from the parent page.
17. How do you handle popups or new tabs?
Difficulty: Intermediate
Question: How do you capture a popup?
Short Interview Answer:
Wait for the page event while performing the action that opens the popup.
Code Example:
const popupPromise = page.waitForEvent(‘popup’);
await page.getByRole(‘link’, {
name: ‘Open Report’
}).click();
const popup = await popupPromise;
await popup.waitForLoadState();
Interview Tip:
Create the event promise before the triggering action.
18. How do you handle file uploads?
Difficulty: Beginner
Question: How do you upload a file?
Short Interview Answer:
Use setInputFiles() on the file input.
Code Example:
await page
.getByLabel(‘Upload document’)
.setInputFiles(‘tests/data/sample.pdf’);
Interview Tip:
Avoid manually interacting with the operating system file picker when Playwright’s file-input API is sufficient.
19. How do you handle downloads?
Difficulty: Intermediate
Question: How do you validate a downloaded file?
Short Interview Answer:
Wait for the download event and then inspect or save the downloaded file.
Code Example:
const downloadPromise = page.waitForEvent(‘download’);
await page.getByRole(‘button’, {
name: ‘Download’
}).click();
const download = await downloadPromise;
await download.saveAs(‘downloads/report.pdf’);
Interview Tip:
Use event-based synchronization instead of fixed sleeps.
20. When should you use CSS or XPath?
Difficulty: Intermediate
Question: Is XPath recommended in Playwright?
Short Interview Answer:
Playwright supports CSS and XPath, but user-facing locators and explicit test contracts are generally preferred because long DOM-dependent selectors are more brittle.
Code Example:
await page.locator(‘button.submit’).click();
await page.locator(‘//button[@type=”submit”]’).click();
Interview Tip:
Say “fallback when appropriate,” not “XPath is forbidden.”
Questions 21–30: POM, Fixtures, Authentication, and API Testing
21. What is Page Object Model in Playwright?
Difficulty: Intermediate
Question: How do you implement POM?
Short Interview Answer:
POM encapsulates page locators and business actions so tests remain readable and UI implementation details are centralized.
Code Example:
export class LoginPage {
constructor(private page: Page) {}
username = this.page.getByLabel(‘Username’);
password = this.page.getByLabel(‘Password’);
login = this.page.getByRole(‘button’, { name: ‘Login’ });
async signIn(user: string, pass: string) {
await this.username.fill(user);
await this.password.fill(pass);
await this.login.click();
}
}
Interview Tip:
Do not turn POM into a dumping ground for every assertion and utility.
22. What are fixtures?
Difficulty: Intermediate
Question: What are Playwright fixtures?
Short Interview Answer:
Fixtures provide test dependencies and setup in an isolated, reusable way. Built-in fixtures include page, context, browser, and request.
Code Example:
test(‘dashboard’, async ({ page }) => {
await page.goto(‘/dashboard’);
});
Here, page is injected by the fixture system.
Interview Tip:
Fixtures are especially useful for framework-level setup and dependency injection.
23. How do you create a custom fixture?
Difficulty: Advanced
Question: How would you provide a logged-in page through a fixture?
Short Interview Answer:
Extend the base test and define a reusable fixture.
Code Example:
import { test as base } from ‘@playwright/test’;
export const test = base.extend<{
loggedInPage: Page;
}>({
loggedInPage: async ({ browser }, use) => {
const context = await browser.newContext({
storageState: ‘playwright/.auth/user.json’
});
const page = await context.newPage();
await use(page);
await context.close();
}
});
Interview Tip:
Explain fixture scope and cleanup.
24. What is storageState?
Difficulty: Intermediate
Question: How does storageState help authentication?
Short Interview Answer:
storageState allows authenticated browser state such as cookies and local storage to be saved and reused, avoiding repeated UI login flows. Playwright recommends keeping authentication state outside source control because it can contain sensitive credentials or cookies.
Code Example:
use: {
storageState: ‘playwright/.auth/user.json’
}
Interview Tip:
Mention .gitignore and secret protection.
25. How do you perform API testing with Playwright?
Difficulty: Intermediate
Question: Can Playwright test APIs?
Short Interview Answer:
Yes. Playwright provides APIRequestContext and the request fixture for making HTTP requests.
Code Example:
test(‘create user’, async ({ request }) => {
const response = await request.post(‘/api/users’, {
data: {
name: ‘John’,
role: ‘tester’
}
});
expect(response.ok()).toBeTruthy();
});
Interview Tip:
Explain that API tests can also prepare test data for UI tests.
26. How do you mock network requests?
Difficulty: Advanced
Question: How can you mock an API response?
Short Interview Answer:
Use page.route() or context-level routing to intercept requests and fulfill them with controlled responses.
Code Example:
await page.route(‘**/api/products’, async route => {
await route.fulfill({
status: 200,
contentType: ‘application/json’,
body: JSON.stringify({
products: [{ id: 1, name: ‘Laptop’ }]
})
});
});
Interview Tip:
Network mocking is valuable for deterministic UI tests and failure simulation.
27. How do you manage test data?
Difficulty: Intermediate
Question: What is your approach to Playwright test data?
Short Interview Answer:
I separate test data from test logic and generate unique data where parallel execution requires isolation.
Code Example:
const user = {
email: `test-${Date.now()}@example.com`,
name: ‘Automation User’
};
Interview Tip:
For large systems, prefer controlled factories, APIs, database setup, or dedicated data services over random data everywhere.
28. What are hooks in Playwright?
Difficulty: Beginner
Question: Explain beforeEach, afterEach, beforeAll, and afterAll.
Short Interview Answer:
Hooks run setup or cleanup around tests or suites.
Code Example:
test.beforeEach(async ({ page }) => {
await page.goto(‘/login’);
});
test.afterEach(async ({ page }) => {
// cleanup
});
Interview Tip:
Avoid putting excessive global setup into hooks because it can make tests harder to understand and debug.
29. How do you test multiple users in one scenario?
Difficulty: Advanced
Question: How would you test an admin and regular user interacting with the same application?
Short Interview Answer:
Create separate BrowserContexts so each user has isolated authentication and storage.
Code Example:
const adminContext = await browser.newContext({
storageState: ‘admin.json’
});
const userContext = await browser.newContext({
storageState: ‘user.json’
});
const adminPage = await adminContext.newPage();
const userPage = await userContext.newPage();
Playwright explicitly supports multiple isolated contexts within a single test.
Interview Tip:
This is a strong senior-level BrowserContext question.
30. How would you combine API and UI testing?
Difficulty: Advanced
Question: How can API testing improve UI automation?
Short Interview Answer:
Use APIs to create, configure, or clean up test data, then validate the resulting behavior through the UI.
Code Example:
const response = await request.post(‘/api/orders’, {
data: { productId: 101 }
});
const order = await response.json();
await page.goto(`/orders/${order.id}`);
await expect(
page.getByText(‘Order created’)
).toBeVisible();
Interview Tip:
API-driven setup can dramatically reduce unnecessary UI setup time.
Questions 31–40: Debugging, Parallel Execution, Reporting, and CI/CD
31. How do you debug a failing Playwright test?
Difficulty: Intermediate
Question: What is your debugging process?
Short Interview Answer:
I reproduce the failure, inspect the locator and application state, use Playwright Inspector or trace viewer, review screenshots/logs, and determine whether the issue is test, application, data, or environment related.
Code Example:
npx playwright test tests/login.spec.ts –debug
Interview Tip:
Describe a structured debugging process rather than saying “I increase the timeout.”
32. What is Playwright Trace Viewer?
Difficulty: Intermediate
Question: Why is tracing useful?
Short Interview Answer:
Trace Viewer lets you inspect test actions, screenshots, DOM snapshots, network activity, and other execution information after a run. Playwright recommends configuring tracing through Playwright Test for richer debugging information.
Code Example:
use: {
trace: ‘retain-on-failure’
}
Interview Tip:
Traces are particularly valuable for failures that cannot be reproduced locally.
33. How do you configure screenshots and videos?
Difficulty: Beginner
Question: How do you capture evidence of failures?
Short Interview Answer:
use: {
screenshot: ‘only-on-failure’,
video: ‘retain-on-failure’
}
Detailed Explanation:
Failure-only capture usually provides useful diagnostics without unnecessarily increasing storage.
Interview Tip:
Balance observability with CI storage costs.
34. How does Playwright execute tests in parallel?
Difficulty: Intermediate
Question: How do workers work?
Short Interview Answer:
Playwright Test can distribute tests across worker processes. Parallel execution reduces wall-clock time when tests are isolated and the environment can handle the load.
Code Example:
export default defineConfig({
workers: process.env.CI ? 4 : undefined
});
Interview Tip:
More workers do not always mean faster execution.
35. What is test sharding?
Difficulty: Advanced
Question: How do you distribute a large test suite across CI machines?
Short Interview Answer:
Use sharding to divide the suite among multiple CI jobs.
Code Example:
npx playwright test –shard=1/4
Other jobs run:
–shard=2/4
–shard=3/4
–shard=4/4
Interview Tip:
Explain the difference between workers and shards: workers parallelize within a job; shards distribute the suite across jobs.
36. How do you run Playwright in GitHub Actions?
Difficulty: Intermediate
Question: What are the key GitHub Actions steps?
Short Interview Answer:
Checkout code, install Node dependencies, install Playwright browsers, run tests, and upload artifacts.
Code Example:
– uses: actions/checkout@v4
– uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
– run: npm ci
– run: npx playwright install –with-deps
– run: npx playwright test
Interview Tip:
Always mention artifact collection for failed tests.
37. How do you run Playwright in Docker?
Difficulty: Intermediate
Question: Why use Docker?
Short Interview Answer:
Docker provides a reproducible environment containing the required runtime and browser dependencies.
Code Example:
FROM mcr.microsoft.com/playwright:v1.55.0-noble
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
CMD [“npx”, “playwright”, “test”]
Interview Tip:
Pin versions for reproducibility rather than depending blindly on latest.
38. How do you handle flaky Playwright tests?
Difficulty: Advanced
Question: A test fails intermittently. What do you do?
Short Interview Answer:
I identify the root cause instead of simply increasing retries. I investigate timing, locators, test data, shared state, network conditions, parallelism, and application race conditions.
Code Example:
retries: process.env.CI ? 1 : 0
Interview Tip:
Retries are a safety net, not a flaky-test solution.
39. Why does a Playwright test pass locally but fail in CI?
Difficulty: Scenario-Based
Question: How do you debug this situation?
Short Interview Answer:
Compare Node versions, browser versions, environment variables, viewport, headless mode, CPU/memory, network, authentication, test data, and worker count.
Code Example:
npx playwright –version
node –version
Interview Tip:
Think in terms of environment parity.
40. How would you design Playwright reporting?
Difficulty: Advanced
Question: What reporting strategy would you use?
Short Interview Answer:
Use an HTML report for interactive investigation, CI artifacts for failed execution evidence, and optionally integrate structured results with centralized test-management or observability systems.
Code Example:
reporter: [
[‘html’, { open: ‘never’ }],
[‘list’]
]
Interview Tip:
Reporting should support debugging and quality decisions, not just produce attractive dashboards.
Questions 41–50: Advanced and Scenario-Based Playwright Questions
41. How would you design a scalable Playwright framework?
Difficulty: Advanced
Question: Design a framework for thousands of tests.
Short Interview Answer:
I would separate tests, page/component objects, fixtures, configuration, test data, API clients, utilities, and reporting. I would also design for isolation, parallelism, observability, and CI execution.
Architecture:
playwright/
├── tests/
├── pages/
├── components/
├── fixtures/
├── api/
├── data/
├── utils/
├── auth/
├── config/
└── reports/
Interview Tip:
Framework architecture is about boundaries and maintainability, not creating many folders.
42. How would you handle a locator that matches multiple elements?
Difficulty: Scenario-Based
Question: A button locator causes a strict mode violation. What do you do?
Short Interview Answer:
Identify why multiple elements match, then narrow the locator using role, accessible name, container, filter(), or a stable test ID.
Code Example:
const product = page
.getByRole(‘listitem’)
.filter({ hasText: ‘Laptop’ });
await product.getByRole(‘button’, {
name: ‘Add to cart’
}).click();
Interview Tip:
Do not use .nth() until you understand why the locator is ambiguous.
43. What would you do if an element is visible but cannot be clicked?
Difficulty: Scenario-Based
Question: The element is visible, but click() times out. Why?
Short Interview Answer:
Visibility is only one actionability condition. The element may be moving, disabled, covered by another element, or unable to receive pointer events. Playwright checks several conditions before clicking.
Code Example:
await expect(button).toBeVisible();
await expect(button).toBeEnabled();
await button.click();
Interview Tip:
Do not immediately use { force: true }. Diagnose the UI first.
44. How would you handle a dynamically changing React component?
Difficulty: Advanced
Question: A component is destroyed and recreated after every update. How do you write a reliable locator?
Short Interview Answer:
Use a locator rather than storing a stale element reference, and choose a stable semantic locator.
Code Example:
const save = page.getByRole(‘button’, {
name: ‘Save’
});
await save.click();
await save.click();
Playwright resolves locators against the current DOM when actions are performed, which helps with re-rendering scenarios.
Interview Tip:
Explain the difference between a locator and a previously captured DOM element.
45. How would you test a payment workflow without calling the real payment provider?
Difficulty: Scenario-Based
Question: How would you make a payment test deterministic?
Short Interview Answer:
Mock the payment provider’s network response or use a test environment with a dedicated payment sandbox.
Code Example:
await page.route(‘**/payments/charge’, async route => {
await route.fulfill({
status: 200,
body: JSON.stringify({
status: ‘approved’
}),
contentType: ‘application/json’
});
});
await page.getByRole(‘button’, {
name: ‘Pay’
}).click();
Interview Tip:
Explain what you are testing: your application’s payment integration behavior, not the external provider itself.
46. How would you prevent test-data conflicts during parallel execution?
Difficulty: Advanced
Question: Tests pass sequentially but fail in parallel. What is your solution?
Short Interview Answer:
Create isolated data per test or worker, avoid shared mutable accounts, and use API/database factories or unique identifiers.
Code Example:
const email =
`user-${testInfo.workerIndex}-${Date.now()}@example.com`;
Interview Tip:
Test isolation is an architectural requirement for reliable parallel execution.
47. How would you optimize a 10,000-test Playwright suite?
Difficulty: Advanced
Question: A regression suite takes hours. What would you change?
Short Interview Answer:
Profile execution first, then use parallel workers, CI sharding, API-driven setup, reusable authentication state, risk-based test selection, efficient fixtures, and selective cross-browser execution.
Example:
npx playwright test –shard=1/8
Interview Tip:
Optimization should be based on execution data, not simply increasing workers.
48. How would you handle authentication securely in CI?
Difficulty: Advanced
Question: How do you avoid logging in through the UI for every test while keeping authentication secure?
Short Interview Answer:
Generate authenticated state using a dedicated setup process, store it securely outside source control, and reuse it through storageState. Authentication state can contain sensitive cookies and headers, so it must be protected.
Code Example:
use: {
storageState: ‘playwright/.auth/user.json’
}
Interview Tip:
Never commit authentication state files.
49. How would you investigate a CI-only timeout?
Difficulty: Scenario-Based
Question: A test consistently times out only in CI. What is your debugging strategy?
Short Interview Answer:
I would inspect the trace, screenshot, logs, browser version, CPU/memory constraints, network timing, environment configuration, and test-data state. Then I would reproduce locally under similar conditions.
Code Example:
use: {
trace: ‘retain-on-failure’,
screenshot: ‘only-on-failure’
}
Interview Tip:
A timeout is a symptom, not a root cause.
50. How would you migrate a large Selenium framework to Playwright?
Difficulty: Advanced / Senior SDET
Question: How would you migrate an enterprise Selenium framework?
Short Interview Answer:
I would perform an incremental migration rather than blindly converting every Selenium statement. First I would audit the existing framework, identify high-value tests, map architecture concepts, redesign locators and waits, establish Playwright fixtures and CI, then migrate and measure results.
Migration Map:
| Selenium | Playwright |
| WebDriver | Browser / BrowserContext / Page |
| WebElement | Locator |
| Explicit waits | Auto-waiting + assertions |
| By selectors | Playwright locators |
| Driver sessions | BrowserContexts |
| TestNG/JUnit | Playwright Test or supported runner |
| Grid | CI workers/sharding/cloud infrastructure |
| Cookies | Context storage |
| Selenium screenshots | Playwright artifacts/traces |
Code Example:
Selenium:
driver.findElement(
By.id(“username”)
).sendKeys(“john”);
Playwright:
await page.getByLabel(‘Username’).fill(‘john’);
Interview Tip:
The best migration answer includes ROI, test stability, team skills, browser requirements, CI infrastructure, and maintenance cost.
Practical Playwright TypeScript Coding Questions
These coding exercises are especially useful after completing the top 50 Playwright interview questions.
Coding Question 1: Login
test(‘login’, async ({ page }) => {
await page.goto(‘/login’);
await page.getByLabel(‘Username’).fill(‘john’);
await page.getByLabel(‘Password’).fill(‘secret’);
await page.getByRole(‘button’, {
name: ‘Login’
}).click();
await expect(page).toHaveURL(/dashboard/);
});
What interviewers assess: locators, assertions, async/await, and synchronization.
Coding Question 2: Table Row
const row = page
.getByRole(‘row’)
.filter({ hasText: ‘John Smith’ });
await row.getByRole(‘button’, {
name: ‘Edit’
}).click();
What interviewers assess: chaining and filtering.
Coding Question 3: API + UI
const response = await request.post(‘/api/products’, {
data: { name: ‘Laptop’ }
});
expect(response.ok()).toBeTruthy();
await page.goto(‘/products’);
await expect(
page.getByText(‘Laptop’)
).toBeVisible();
What interviewers assess: hybrid automation design.
Common Mistakes Candidates Should Avoid
1. Memorizing syntax without understanding architecture
Know why BrowserContext exists and why locators behave differently from raw DOM references.
2. Saying Playwright never needs waits
Playwright provides auto-waiting, but a test can still fail if the required condition never becomes true.
3. Using waitForTimeout() everywhere
Fixed delays are usually a poor synchronization strategy.
4. Using XPath for everything
Prefer stable, user-facing locators when they express the intended behavior.
5. Using nth() to hide strict-mode problems
First understand why multiple elements match.
6. Treating retries as a flaky-test solution
Retries can expose intermittent failures but should not replace root-cause analysis.
7. Ignoring test isolation
Parallel tests must not depend on shared mutable state.
8. Committing authentication state
Authentication state can contain sensitive cookies and headers. Keep it outside source control.
9. Designing POM without architecture
A page-object class should have clear responsibilities. Avoid putting unrelated utilities into every page class.
10. Ignoring CI/CD
Modern SDET interviews increasingly evaluate whether you can run and debug automation outside your laptop.
Playwright Interview Preparation Roadmap
Phase 1: Freshers
Learn:
- Playwright fundamentals
- Browser
- BrowserContext
- Page
- Locators
- Assertions
- Basic navigation
- Forms
- Screenshots
- Frames
- Popups
Start with Playwright Interview Questions for Freshers.
Phase 2: Intermediate Engineers
Add:
- Strict mode
- Auto-waiting
- POM
- Fixtures
- Authentication
- storageState
- API testing
- Network mocking
- Test data
- Parallel execution
- Reporting
Study Playwright TypeScript Interview Questions, Playwright Locators Interview Questions, and Playwright API Testing Interview Questions.
Phase 3: Experienced Engineers
Focus on:
- CI/CD
- GitHub Actions
- Docker
- Sharding
- Cross-browser testing
- Flaky-test analysis
- Framework architecture
- Test isolation
- Performance optimization
Study Playwright CI/CD Interview Questions and Playwright Framework Design Interview Questions.
Phase 4: Senior SDET / QA Lead
Practice explaining:
- Framework scalability
- Migration from Selenium
- Test strategy
- Quality gates
- CI architecture
- Test observability
- Data isolation
- Authentication strategy
- Cost optimization
- Cross-browser strategy
- Long-term maintainability
Also study Advanced Playwright Automation Techniques and Playwright Test Architecture for Large Projects.
Interview Difficulty Checklist
| Topic | Fresher | Intermediate | Senior |
| Basic syntax | ✓ | ✓ | ✓ |
| Locators | ✓ | ✓ | ✓ |
| Assertions | ✓ | ✓ | ✓ |
| BrowserContext | ✓ | ✓ | ✓ |
| POM | — | ✓ | ✓ |
| Fixtures | — | ✓ | ✓ |
| API testing | — | ✓ | ✓ |
| Authentication | — | ✓ | ✓ |
| Network mocking | — | ✓ | ✓ |
| CI/CD | — | ✓ | ✓ |
| Sharding | — | — | ✓ |
| Architecture | — | ✓ | ✓ |
| Migration | — | — | ✓ |
| Scalability | — | — | ✓ |
FAQs: Top 50 Playwright Interview Questions
What are the most asked Playwright interview questions?
Common questions cover Playwright architecture, BrowserContext, Page, locators, auto-waiting, assertions, POM, fixtures, authentication, API testing, network mocking, parallel execution, CI/CD, and debugging.
Is Playwright easy to learn for Selenium testers?
Yes. Many concepts map naturally, but Selenium engineers should pay particular attention to BrowserContext, Locator, fixtures, auto-waiting, and Playwright’s test runner.
What should freshers study for Playwright interviews?
Freshers should master Playwright fundamentals, browser/page concepts, locators, assertions, navigation, forms, waits, screenshots, frames, and basic POM.
What should experienced Playwright engineers know?
Experienced engineers should know fixtures, authentication, API testing, network interception, parallel execution, sharding, CI/CD, reporting, test data management, and framework architecture.
What is the most important Playwright concept?
There is no single concept, but locators, auto-waiting, and test isolation are especially important because they influence reliability and maintainability.
Is Playwright better than Selenium?
There is no universal answer. Playwright can be highly effective for modern web applications, while Selenium remains valuable for mature WebDriver-based ecosystems and organizations with established infrastructure.
Does Playwright support API testing?
Yes. Playwright provides request APIs that can be used for API testing and test-data setup.
What is storageState in Playwright?
storageState allows authentication-related browser state to be saved and reused between tests or projects.
How does Playwright handle flaky tests?
It provides isolation, auto-waiting, retries, traces, screenshots, and parallel execution features, but flaky tests still require root-cause analysis.
What should I learn after these 50 questions?
After completing these top 50 Playwright interview questions, practice scenario-based automation, TypeScript coding, API testing, CI/CD, framework architecture, and Selenium-to-Playwright migration.
