
Playwright has become one of the most popular automation testing frameworks due to its speed, reliability, and cross-browser support. Many organizations are replacing Selenium with Playwright because of its modern architecture, built-in waiting mechanisms, API testing capabilities, and excellent support for parallel execution.
If you're preparing for a QA Automation Engineer, SDET, Software Test Engineer, or Automation Test Lead interview, this guide covers the top 50 Playwright interview questions with detailed answers and practical examples.
Playwright Fundamentals
Locators & Selectors
Page Object Model
Auto-Waiting
Frames & Windows
API Testing
Playwright Test Runner
CI/CD Integration
Debugging & Reporting
Scenario-Based Questions
Playwright is an open-source browser automation framework developed by Microsoft. It supports end-to-end testing across Chromium, Firefox, and WebKit using a single API.
Cross-browser testing
Cross-platform support
Auto-waiting
Parallel execution
API testing
Mobile emulation
Multiple tabs
Network interception
Screenshots & videos
Trace Viewer
PlaywrightSeleniumAuto WaitingManual waits requiredFaster executionComparatively slowerAPI Testing includedSeparate libraries neededMultiple browser contextsLimited supportBuilt-in tracingExternal toolsBetter parallel executionConfiguration required
Playwright supports:
Chromium
Google Chrome
Microsoft Edge
Firefox
Safari (WebKit)
JavaScript
TypeScript
Python
Java
.NET (C#)
Browser: Represents the browser instance.
Browser Context: An isolated browser session with separate cookies and storage.
Page: A browser tab within a context.
Example:
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();Locators identify UI elements for interaction.
Examples:
page.getByRole()
page.getByText()
page.getByLabel()
page.getByPlaceholder()
page.getByTestId()
page.locator()Priority:
getByRole()
getByLabel()
getByPlaceholder()
getByTestId()
CSS Locator
XPath (last option)
locator() accepts CSS/XPath selectors and is flexible.
getByRole() uses accessibility roles and is generally more resilient to UI changes.
Examples:
page.locator('tr').filter({
hasText:'Playwright'
})
page.locator('button').nth(2)
page.locator('[data-testid="login"]')await page.locator('.btn').first().click();Playwright automatically waits until elements are:
Visible
Stable
Enabled
Ready for interaction
This reduces the need for explicit waits.
Using fixed delays:
Slows tests
Makes tests flaky
Doesn't adapt to application speed
Prefer waiting for specific elements or states.
await page.locator('#submit').waitFor({
state:'visible'
});await page.waitForLoadState('load');
await page.waitForLoadState('domcontentloaded');
await page.waitForLoadState('networkidle');Auto Waiting is built into Playwright for actions like click() and fill().
Explicit waits are used for custom conditions, such as waiting for a specific element or API response.
POM is a design pattern where each page is represented by a class containing locators and methods.
Benefits:
Reusability
Maintainability
Readability
Easier updates
export class LoginPage{
constructor(private page:Page){}
readonly username=this.page.getByLabel('Username');
readonly password=this.page.getByLabel('Password');
readonly login=this.page.getByRole('button',{name:'Login'});
}A BasePage stores common actions:
Click
Fill
Wait
Navigation
Screenshots
This reduces duplicate code.
Recommended structure:
tests/
pages/
fixtures/
utils/
data/
config/
reports/
playwright.config.ts
package.jsonFixtures manage reusable setup and teardown logic.
Example:
test.use({
storageState:'auth.json'
});await page.frameLocator('#frame')
.getByRole('button')
.click();const newPage = await context.waitForEvent('page');const popup = await page.waitForEvent('popup');page.on('dialog', async dialog => {
await dialog.accept();
});await page.setInputFiles('input', './sample.pdf');Yes.
Playwright provides an APIRequestContext for API testing without requiring additional libraries.
const response = await request.get('/users');
expect(response.ok()).toBeTruthy();await request.post('/login',{
data:{
username:'admin'
}
});A common workflow is to create test data through an API and then validate it in the UI. This reduces execution time and improves test stability.
expect(awaitresponse.json()).toHaveProperty('id');Parallel execution
Retries
Hooks
Fixtures
Projects
HTML reports
beforeAll() beforeEach() afterEach() afterAll()npx playwright test login.spec.tsnpx playwright test --headednpx playwright test --debugPipeline stages:
Install dependencies
Run tests
Publish reports
Archive artifacts
Typical YAML steps:
- npm install
- npx playwright install
- npx playwright testExample workflow:
- uses: actions/setup-node
- run: npm ci
- run: npx playwright testDocker provides consistent execution environments, eliminates machine-specific issues, and simplifies CI/CD integration.
workers:4This speeds up test execution by running tests concurrently.
Playwright Inspector
Trace Viewer
Screenshots
Videos
Console logs
VS Code Debugger
Trace Viewer records actions, network requests, screenshots, and DOM snapshots, making it easier to diagnose failures.
npx playwright show-reportawait page.screenshot({
path:'home.png'
});Enable video recording in playwright.config.ts:
use:{
video:'retain-on-failure'
}Verify the locator.
Check if another element or overlay is intercepting the click.
Wait for the element to become stable.
Scroll it into view.
Inspect with Playwright Inspector.
Avoid using force: true unless absolutely necessary.
Use stable locators.
Rely on auto-waiting.
Eliminate fixed waits.
Isolate test data.
Keep tests independent.
Investigate failures instead of masking them with retries.
Possible causes:
Environment differences
Missing dependencies
Timing issues
Network latency
Browser version mismatch
Use the Page Object Model.
Centralize common actions in a BasePage.
Store test data externally.
Separate configuration by environment.
Integrate reporting and CI/CD.
A strong answer should include:
Project structure
Page Object Model
BasePage utilities
Fixtures
Environment configuration
Reporting
Logging
CI/CD integration
Test data management
Parallel execution strategy
Be ready to explain your framework architecture.
Practice writing locators without relying on XPath.
Learn Playwright debugging tools.
Understand CI/CD integration.
Explain how you handle flaky tests.
Prepare real-world examples from your projects.
Demonstrate familiarity with API testing and browser contexts.
Understand the difference between Playwright and Selenium.
Playwright has become a leading framework for modern web automation due to its speed, reliability, and rich feature set. Success in a Playwright interview depends on more than memorizing commands—you should understand automation design patterns, debugging strategies, CI/CD integration, and real-world testing scenarios.
Master these 50 questions, practice building frameworks, and gain hands-on experience with end-to-end, API, and cross-browser testing to confidently prepare for your next QA Automation Engineer, SDET, or Playwright Automation Engineer interview.

Facebook
Instagram
X
LinkedIn
Youtube
WhatsApp