[go: up one dir, main page]

0% found this document useful (0 votes)
174 views3 pages

Playwright Interview Questions and Answers

The document provides a comprehensive list of the top 30 interview questions and answers related to Playwright, an open-source test automation library for web applications. It covers various aspects including browser support, languages, features, and specific functionalities such as auto-waiting, handling alerts, and running tests in parallel. Additionally, it explains how to mock API responses, debug tests, and manage test configurations.

Uploaded by

Marlon Cabraca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
174 views3 pages

Playwright Interview Questions and Answers

The document provides a comprehensive list of the top 30 interview questions and answers related to Playwright, an open-source test automation library for web applications. It covers various aspects including browser support, languages, features, and specific functionalities such as auto-waiting, handling alerts, and running tests in parallel. Additionally, it explains how to mock API responses, debug tests, and manage test configurations.

Uploaded by

Marlon Cabraca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Top 30 Playwright Interview Questions & Answers

1. Q: What is Playwright?
A: Playwright is an open-source test automation library by Microsoft for end-to-end testing of web
apps using Node.js, supporting multiple browsers.

2. Q: Which browsers does Playwright support?


A: Chromium, Firefox, and WebKit (Safari engine).

3. Q: What languages can you use with Playwright?


A: JavaScript, TypeScript, Python, Java, and C#.

4. Q: How is Playwright different from Selenium?


A: Playwright supports modern web app features out-of-the-box like auto-waiting, multiple browser
contexts, and better handling of single-page apps.

5. Q: What is auto-waiting in Playwright?


A: Playwright automatically waits for elements to be ready before performing actions.

6. Q: How do you launch a browser in Playwright?


A: `const browser = await playwright.chromium.launch();`

7. Q: How do you create a new browser context?


A: `const context = await browser.newContext();`

8. Q: What is a browser context?


A: A context is like a new browser profile. It allows multiple sessions in one browser instance.

9. Q: How do you interact with a dropdown in Playwright?


A: Use `page.selectOption(selector, value)` to choose an option.

10. Q: How to take a screenshot in Playwright?


A: Use `page.screenshot({ path: 'screenshot.png' })`.

11. Q: What is `page.waitForSelector`?


A: It waits for an element matching the selector to appear in the DOM.

12. Q: How to perform assertions in Playwright?


A: Use Playwright Test or expect library: `expect(element).toHaveText('text')`.

13. Q: What is the role of fixtures in Playwright Test?


A: Fixtures help set up and tear down test environments, like browser or context.

14. Q: What is headless mode?


A: Running browser tests without a GUI. It's faster and common in CI pipelines.

15. Q: How do you handle file uploads in Playwright?


A: Use `setInputFiles()` with the file path.

16. Q: How can you record tests in Playwright?


A: Use `npx playwright codegen <URL>` to generate test scripts by recording actions.

17. Q: How do you run tests in parallel?


A: Playwright Test runs tests in parallel by default at the file level.

18. Q: How do you handle alerts/popups?


A: Use `page.on('dialog', async dialog => { await dialog.accept(); })`.

19. Q: Can Playwright test mobile views?


A: Yes, using `viewport` and `userAgent` settings in context for mobile emulation.

20. Q: How to debug Playwright tests?


A: Use `DEBUG=pw:api` or `--debug` flag in CLI; `headless: false` for visual debugging.

21. Q: What is Playwright Test Runner?


A: It's a built-in test runner with features like parallelism, retries, reporters, and fixtures.

22. Q: How do you mock API responses?


A: Use `page.route()` to intercept and modify network requests.

23. Q: What is `tracing` in Playwright?


A: Tracing helps analyze test execution with detailed traces: `context.tracing.start()` and
`context.tracing.stop()`.

24. Q: How to run tests in different browsers?


A: Use `--project=chromium/firefox/webkit` in Playwright config.

25. Q: What is the purpose of Playwright config file?


A: Central place to define test settings like baseURL, retries, timeouts, projects.

26. Q: How to handle flaky tests?


A: Use `retries` in config, better selectors, and proper wait mechanisms.

27. Q: How do you test authentication flows?


A: Use storage state or context login to persist sessions across tests.

28. Q: What is the difference between `locator` and `page.$`?


A: `locator` is recommended and resilient to changes; `$` fetches once and can become stale.

29. Q: How do you test if a button is disabled?


A: `expect(button).toBeDisabled()` or check attribute manually.
30. Q: How do you assert an element is visible?
A: Use `expect(locator).toBeVisible()`.

You might also like