Playwright Testing

52 Playwright Interview Questions and Answers for QA Engineers

Prepare for Playwright interviews with 52 beginner, intermediate, and advanced questions covering automation, API testing, fixtures, CI/CD, MCP, Agents, and best practices.

52 Playwright Interview Questions and Answers

If you are preparing for a Playwright interview, this guide covers beginner, intermediate, and advanced questions that QA engineers, automation testers, and SDETs commonly need to understand.

From basic Playwright concepts such as locators, auto-waiting, and browser contexts to advanced topics such as Playwright MCP, Agents, test sharding, CHIPS, and the HTML Report Speedboard, these questions can help you prepare for your next automation testing interview.

Beginner Playwright Interview Questions

1. What is Playwright and why is it used?

Playwright is an open-source automation testing framework developed by Microsoft. It is used to automate web applications and perform end-to-end testing across different browsers. Playwright is popular because it is fast, reliable, and provides built-in features such as auto-waiting and parallel execution.

2. What browsers does Playwright support?

Playwright supports three major browser engines: Chromium, Firefox, and WebKit This allows testers to run the same test script across multiple browsers and verify cross-browser compatibility.

3. How do you install Playwright?

Playwright can be installed using: npm init playwright@latest This command installs Playwright, the required browsers, and creates a sample project structure.

4. What is a Locator in Playwright?

A Locator is used to find and interact with elements on a web page in Playwright. It supports auto-waiting and helps create reliable and stable automation scripts. Examples: getByRole() getByText() getByLabel()

5. What is auto-waiting in Playwright?

Auto-waiting is a Playwright feature that automatically waits for an element to become ready before performing an action. This reduces failures caused by loading delays and eliminates the need for most manual waits.

6. How do you write a basic Playwright test?

A basic Playwright test contains three main steps: Open a webpage. Perform actions on the page. Verify the expected result using assertions. The test() function is used to create test cases, while expect() is used for validations.

7. How do you run Playwright tests?

Playwright tests can be executed using: npx playwright test You can also run specific test files, execute tests in headed mode, or run tests on a specific browser.

8. What is playwright.config.ts?

playwright.config.ts is the main configuration file of a Playwright project. It manages settings such as: Browser configuration, Timeouts, Retries, Reporters, Test execution options, and Base URLs

9. What is the difference between a Page and a BrowserContext?

A Page represents a single browser tab, while a BrowserContext represents an isolated browser session. Multiple pages can exist inside one BrowserContext, and each context has its own cookies and storage data.

10. How do you take screenshots in Playwright?

Playwright provides a built-in screenshot() method. Screenshots can be captured for the entire page or a specific element and are commonly used for debugging and reporting.

11. How do you handle dropdowns and select elements?

For standard HTML dropdowns, Playwright uses the selectOption() method. For custom dropdowns, testers generally perform click actions and select the required option using locators.

12. What is headed vs headless mode?

Headless mode runs the browser without displaying the UI and is generally faster for automation. Headed mode opens the browser window and is mainly useful for debugging and observing test execution.

13. How do you fill input fields and forms?

Playwright provides methods such as fill(), type(), and keyboard actions to enter data into input fields. These methods help automate form submission and user-input scenarios.

14. How do you verify text on a page?

Text verification is performed using Playwright assertions such as expect(). You can verify: Page titles, URLs, Element text, and Visibility This helps ensure the application behaves as expected.

15. What is the Playwright Test Runner?

The Playwright Test Runner is the built-in framework used to create, execute, and manage Playwright tests. It provides features such as: Fixtures, Parallel execution, Retries, Reporting, Hooks, and Assertions

Intermediate Playwright Interview Questions

16. What are fixtures in Playwright?

Fixtures are reusable components used to set up and manage test resources. They help reduce duplicate code and provide objects such as page, browser, and context automatically to test cases.

17. How does Playwright handle iframes?

Playwright handles iframes using frame() and frameLocator(). The recommended approach is frameLocator() because it allows reliable interaction with elements inside an iframe.

18. How do you handle file uploads?

Playwright handles file uploads using the setInputFiles() method. It allows testers to upload one or multiple files without interacting with the operating system's file picker.

19. How do you intercept and mock network requests?

Playwright uses the route() method to intercept network requests. It allows testers to modify, block, or mock API responses, making testing faster and less dependent on external services. For broader API automation concepts, see API Testing.

20. What is the Page Object Model (POM) in Playwright?

Page Object Model (POM) is a design pattern where page elements and actions are stored in separate classes. It improves: Code reusability Readability Maintainability POM is commonly used when building scalable test automation frameworks.

21. How do you run tests in parallel?

Playwright supports parallel execution using multiple workers. Running tests in parallel reduces execution time and improves overall test-suite performance.

22. What is storageState? How do you save a login session?

storageState is used to save browser session data such as cookies and local storage. It allows testers to reuse login sessions across tests and avoid performing login repeatedly.

23. How do you handle dialogs such as alert, confirm, and prompt?

Playwright handles browser dialogs using the dialog event. Testers can accept, dismiss, or provide input to: Alerts, Confirmation boxes, and Prompt dialogs

24. What is visual testing and how do you do it in Playwright?

Visual testing compares the current UI with a previously saved screenshot. Playwright supports visual testing through screenshot comparison, helping detect unexpected UI changes.

25. How do you handle multiple windows or new tabs?

Playwright can detect and switch to newly opened tabs or windows using browser-context events. This allows testers to interact with multiple pages during a test.

26. How do you do API testing in Playwright?

Playwright provides built-in API testing through APIRequestContext. It allows testers to send HTTP requests and validate API responses without using separate tools. For more information, see What Is API Testing?.

27. What are test annotations in Playwright?

Test annotations are used to control test behavior. Common annotations include: skip only fail fixme slow They help manage test execution and reporting.

28. What reporters does Playwright support?

Playwright supports multiple reporters, including: HTML, List, Dot, JSON, and JUnit Reporters help generate test-execution results in different formats.

29. How do you use beforeEach and afterEach hooks?

beforeEach runs before every test, while afterEach runs after every test. They are commonly used for setup and cleanup activities such as: Login, Logout, and Test-data preparation

30. How do you handle hover and drag-and-drop?

Playwright provides built-in mouse actions such as hover() and dragTo() for automating interactions with menus, sliders, and draggable elements.

31. What is the Playwright Trace Viewer?

Trace Viewer is a debugging tool in Playwright that records test execution details, including: Screenshots, Network requests, Actions, and Logs It helps testers quickly identify and troubleshoot test failures.

32. What is Codegen and how do you use it?

Codegen is Playwright's test-recording tool. It automatically generates Playwright code based on user actions performed in the browser, making initial test creation faster and easier.

33. How do you implement global setup and teardown?

Global setup runs before all tests, while global teardown runs after all tests. They can be used for: Creating test data, Configuring environments, and Cleaning up resources

34. What is ARIA snapshot testing?

ARIA snapshot testing verifies the accessibility structure of a webpage. It helps ensure that screen readers and accessibility tools can correctly understand and interact with an application.

35. How do you run Playwright tests in CI/CD?

Playwright tests can be integrated into CI/CD pipelines such as: GitHub Actions, Jenkins, Azure DevOps, and GitLab CI This allows automated test execution whenever code changes are pushed. You can also learn more about Jenkins in Automation Testing.

36. What is test sharding in Playwright?

Test sharding divides test cases across multiple machines or environments. This helps reduce overall execution time and improves testing efficiency.

37. What is the difference between request fixture and APIRequestContext?

The request fixture is a built-in Playwright feature used directly inside test cases for API testing. APIRequestContext provides more flexibility and can be created separately for custom API interactions and configurations.

38. How do you handle flaky tests in Playwright?

Flaky tests can be reduced by: Using reliable locators, Avoiding hard-coded waits, Implementing retries appropriately, Using auto-waiting, and Analyzing failures with Trace Viewer

39. How do you test mobile devices in Playwright?

Playwright supports mobile testing through device emulation. It can simulate: Mobile devices, Screen sizes, User agents, and Touch interactions This allows testers to validate responsive web applications without requiring a physical device.

40. How do you test Chrome extensions in Playwright?

Playwright allows testers to load Chrome extensions during browser launch. This helps verify extension functionality, UI behavior, and user interactions.

41. What is the webServer option in Playwright config?

The webServer option automatically starts an application server before tests begin. This ensures that the application is available when Playwright starts executing tests.

42. How do you create custom matchers in Playwright?

Custom matchers allow testers to create reusable assertions based on project-specific requirements. They improve readability and make validations easier to maintain across test cases.

Advanced Playwright Interview Questions

43. What is Playwright MCP (Model Context Protocol)?

Playwright MCP is a protocol that allows AI tools and agents to interact with browsers using Playwright. It can help AI systems perform browser actions, generate tests, and automate workflows using natural-language instructions.

44. What are Playwright Agents?

Playwright Agents are AI-powered features designed to assist with test creation and maintenance. They can analyze applications, suggest test scenarios, and help reduce manual testing effort. For a deeper look, see How Playwright Test Agents Are Changing the Game in E2E Automation.

45. What changed with Chrome for Testing in Playwright v1.57?

Playwright started using Chrome for Testing instead of standard Chromium builds. This provides a browser environment closer to real-world Chrome and can improve test accuracy and reliability.

46. What are Locator.describe() and Locator.description()?

These methods allow testers to add meaningful descriptions to locators. The descriptions can appear in reports and error messages, making test failures easier to understand and debug.

47. How does Playwright support IndexedDB in storage state?

Playwright can save and restore IndexedDB data as part of browser storage state. This helps preserve application sessions and user data for tests that rely on IndexedDB.

48. What is the HTML Report Speedboard?

Speedboard is a feature in Playwright's HTML report that provides a visual view of test-execution timelines. It helps teams identify slow-running tests and improve overall test-suite performance.

49. What is the Worker.onConsole event?

Worker.onConsole captures console messages generated by Web Workers. It helps testers monitor logs and debug issues occurring inside background worker processes.

50. How does Playwright compare to Selenium and Cypress?

Playwright is generally fast and provides built-in auto-waiting, parallel execution, and multi-browser support. Compared with Cypress, Playwright offers strong support for multiple tabs, iframes, and cross-browser testing. For a broader comparison, see Cypress vs Selenium: Key Differences.

51. What is partitioned cookie (CHIPS) support in Playwright?

CHIPS, or Cookies Having Independent Partitioned State, is a browser privacy feature that separates cookies based on their context. Playwright supports testing partitioned cookies to help ensure applications work correctly with modern browser privacy standards.

52. What are the best practices for Playwright automation?

Some important Playwright best practices include:

Use reliable locators such as getByRole() and getByTestId().

Follow the Page Object Model (POM).

Avoid hard-coded waits.

Keep test cases independent.

Use fixtures for reusable setup.

Enable reporting, screenshots, and traces for debugging.

Run tests in parallel whenever possible.

Following these practices helps create stable, maintainable, and scalable test automation frameworks.

Conclusion

Playwright has become an important automation framework for modern QA teams because it combines browser automation, API testing, parallel execution, debugging, reporting, and cross-browser support in a single ecosystem.

For interview preparation, don't focus only on memorizing answers. Practice these concepts by building real automation projects and understanding why each Playwright feature is used.

The strongest candidates can explain both the Playwright feature and the real-world testing problem it solves.


DS
Dhruv Solanki

Senior QA engineers who have stabilized suites across SaaS, FinTech and Enterprise teams since 2017.

Want red to mean red again?

Bring us your flakiest suite. A stabilization pass is one of the fastest-payback things we do.

Book a Scoping Call