Playwright Interview Questions Cheat sheet



If you’re preparing for a Playwright Automation Tester interview (3–10 years experience), these are some of the most commonly asked questions.

Basic Questions

  1. What is Playwright?
  2. Why do you prefer Playwright over Selenium?
  3. Which browsers does Playwright support?
  4. What are the advantages of Playwright?
  5. What are Browser, BrowserContext, and Page?
  6. Can one Browser have multiple BrowserContexts?
  7. What is the difference between BrowserContext and Page?
  8. How do you launch a browser in headless and headed mode?
  9. How do you close the browser properly?

Locator Questions

  1. What types of locators are available in Playwright?
  2. Which locator should you prefer and why?
  3. Difference between:
    • locator()
    • getByRole()
    • getByText()
    • getByLabel()
    • getByTestId()
  4. What happens if multiple elements match a locator?
  5. What is strict mode?
  6. What is locator chaining?
  7. What is .filter()?
  8. Difference between CSS and XPath in Playwright.
  9. Why should XPath be avoided when possible?

Auto Waiting

  1. What is Auto Waiting?
  2. Which actions automatically wait?
  3. Why is Thread.sleep() a bad practice?
  4. Difference between:
    • waitForSelector()
    • waitForLoadState()
    • waitForURL()
  5. What is the default timeout?
  6. How do you change timeout globally?
  7. How do you change timeout for one action?

Browser Context

  1. Why use BrowserContext?
  2. How do you create multiple BrowserContexts?
  3. Can two contexts share cookies?
  4. Can two pages inside one context share session?
  5. Difference between incognito and normal browser.
  6. How do you clear cookies?
  7. How do you save authentication state?
  8. What is storageState()?

Authentication

  1. How do you avoid logging in before every test?
  2. Explain storageState.
  3. What is global setup?
  4. Where should authentication be performed?
  5. How do you reuse login across projects?

Assertions

  1. Difference between:
    • expect(locator).toBeVisible()
    • expect(locator).toHaveText()
  2. Difference between soft and hard assertions.
  3. What are auto-retrying assertions?
  4. How do assertions work internally?

Frames

  1. How do you handle iframe?
  2. Difference between:
    • frameLocator()
    • page.frame()
  3. Nested iframe handling.
  4. How do you switch back from iframe?

Multiple Tabs

  1. How do you handle new tabs?
  2. Difference between popup and new page.
  3. How do you wait for popup?
  4. How do you switch between tabs?

File Upload & Download

  1. How do you upload a file?
  2. Upload hidden input.
  3. Download a file.
  4. Verify downloaded file.
  5. Change download directory.

Alerts

  1. How do you handle alerts?
  2. Difference between alert, confirm, prompt.
  3. How do you capture alert text?

Network

  1. What is Network Interception?
  2. Difference between Mocking and Blocking.
  3. How do you mock an API?
  4. How do you modify API response?
  5. How do you capture request payload?
  6. How do you capture response?
  7. Verify status code.
  8. How do you simulate network failure?

API Testing

  1. What is APIRequestContext?
  2. GET request.
  3. POST request.
  4. Authentication.
  5. Verify JSON response.
  6. Read headers.
  7. Upload files through API.
  8. Chain API and UI tests.

Parallel Execution

  1. How does Playwright execute tests in parallel?
  2. What are Workers?
  3. Difference between parallel and serial mode.
  4. What is workerIndex?
  5. How do you disable parallel execution?

Projects

  1. What are Projects?
  2. Execute same test in Chrome, Firefox and Safari.
  3. Device emulation.
  4. Mobile testing.

Fixtures

  1. What are fixtures?
  2. Built-in fixtures.
  3. Custom fixtures.
  4. Difference between beforeEach and fixtures.
  5. Worker fixture vs Test fixture.

Hooks

  1. Difference between:
    • beforeAll
    • beforeEach
    • afterEach
    • afterAll
  2. When should beforeAll be avoided?
  3. Can hooks run in parallel?

POM (Page Object Model)

  1. Explain Page Object Model.
  2. Advantages.
  3. How do you organize large projects?
  4. Where should locators be stored?
  5. Should assertions be inside page classes?

Data Driven Testing

  1. Read JSON.
  2. Read Excel.
  3. Read CSV.
  4. Parameterized tests.
  5. Dynamic test generation.

Configuration

  1. Explain playwright.config.ts.
  2. baseURL.
  3. retries.
  4. workers.
  5. reporter.
  6. trace.
  7. screenshot.
  8. video.
  9. timeout.
  10. expect timeout.

Reporting

  1. HTML Reporter.
  2. Allure Reporter.
  3. JUnit Reporter.
  4. JSON Reporter.
  5. Custom Reporter.

CI/CD

  1. Execute Playwright in Jenkins.
  2. Execute in Azure DevOps.
  3. Execute in GitHub Actions.
  4. Headless execution.
  5. Docker support.

Debugging

  1. PWDEBUG.
  2. Inspector.
  3. Trace Viewer.
  4. Code Generator.
  5. Screenshots.
  6. Videos.
  7. Console logs.

Advanced Questions

  1. Explain Playwright architecture.
  2. Why is Playwright faster than Selenium?
  3. What is auto-waiting internally?
  4. Difference between Locator and ElementHandle.
  5. Why is ElementHandle discouraged?
  6. Difference between Playwright Test and Jest.
  7. How does Playwright communicate with browsers?
  8. How is synchronization handled?
  9. What is actionability check?
  10. What is strict mode?
  11. Difference between locator.click() and page.click().
  12. Why should locator() be preferred?
  13. Difference between expect.poll() and expect().
  14. How do you test microservices using Playwright?
  15. How do you execute UI and API tests together?

Scenario-Based Questions (Frequently Asked)

  1. How would you automate an OTP-based login?
  2. How would you automate CAPTCHA-protected pages?
  3. How would you handle flaky tests?
  4. A test passes locally but fails in CI. How would you debug it?
  5. How do you test an application across multiple user roles simultaneously?
  6. How would you verify a downloaded PDF?
  7. How would you validate an email received after user registration?
  8. How do you automate drag-and-drop functionality?
  9. How would you test file uploads larger than 100 MB?
  10. How do you handle dynamic tables and pagination?
  11. How do you test applications with frequent UI changes?
  12. How would you optimize a Playwright suite with 5,000+ test cases?
  13. How do you run only failed tests?
  14. How do you implement retries without masking real defects?
  15. How would you integrate Playwright tests into a CI/CD pipeline with parallel execution and reporting?

For senior (6+ years) Playwright roles, interviewers often focus less on syntax and more on framework design, debugging strategies, scalability, CI/CD integration, test architecture, and handling real-world automation challenges. Mastering these areas will significantly improve your performance in technical interviews.

For more Playwright tutorials, examples, and automation concepts, visit our Playwright Tutorial section.

Tags: , ,
Leave a comment

Your email address will not be published. Required fields are marked *

Subscribe now

Receive weekly newsletter with educational materials, new courses, most popular posts, popular books and much more!