Posted in

Top 30 Playwright Interview Questions and Answers for 2026

Prepare for your Playwright interview with this comprehensive guide featuring 30 essential questions and answers. Covering basic, intermediate, and advanced topics, this resource is ideal for freshers, candidates with 1-3 years of experience, and professionals with 3-6 years in automation testing. Master Playwright concepts to excel in technical interviews at companies like Zoho, Salesforce, and Atlassian.

Basic Playwright Interview Questions

1. What is Playwright?

Playwright is an open-source automation framework developed by Microsoft for end-to-end testing of web applications. It supports Chromium, Firefox, and WebKit browsers with a single API, enabling cross-browser testing across platforms.[1][2]

2. What are the key features of Playwright?

Key features include auto-waiting for elements, network interception, cross-browser support, headless mode, and built-in assertions. It also handles modern web apps with features like file upload/download and mobile emulation.[1][3]

3. How do you install Playwright?

Install Playwright using npm with the command npx playwright install after running npm init playwright@latest. This sets up the project structure and downloads required browsers.[4]

4. What is the difference between page.goto() and page.click()?

page.goto(url) navigates to a specified URL, while page.click(selector) performs a click action on an element after performing actionability checks like visibility and stability.[2]

5. How does Playwright handle waiting and synchronization?

Playwright uses auto-waiting with actionability checks before actions. It verifies if elements are attached to DOM, visible, stable, enabled, and ready for events, eliminating manual waits.[1][2]

6. What are locators in Playwright?

Locators identify elements on the page using selectors like CSS, XPath, text, role, or label. Example: page.locator('button:has-text("Submit")').[3]

7. How do you run Playwright tests in headed mode?

Use npx playwright test --headed to run tests with visible browsers. This helps in debugging visual issues during test execution.[4]

8. What is a Playwright fixture?

Fixtures provide reusable test context like page, browser, or context. They are defined in playwright.config.ts for setup and teardown automation.[4]

9. How do you generate HTML reports in Playwright?

Configure reports in playwright.config.ts with reporter: 'html'. Run tests and view the report at playwright-report/index.html.[3]

10. What browsers does Playwright support out-of-the-box?

Playwright supports Chromium (Chrome, Edge), Firefox, and WebKit (Safari) with bundled binaries for reliable cross-browser testing.[1]

Intermediate Playwright Interview Questions

11. Explain the Page Object Model (POM) in Playwright.

POM organizes tests by creating page classes with locators and methods. It improves maintainability for large test suites at companies like Paytm.[1]

class LoginPage {
  constructor(page) { this.page = page; }
  async goto() { await this.page.goto('/login'); }
  async login(user, pass) {
    await this.page.fill('#username', user);
    await this.page.fill('#password', pass);
    await this.page.click('button[type=submit]');
  }
}

12. How do you handle network requests in Playwright?

Use page.route() to mock or intercept network requests. Example: await page.route('**/api/**', route => route.fulfill({ json: { data: 'mocked' } }));[3]

13. What is the role of playwright.config.ts?

This configuration file defines projects, reporters, timeouts, retries, and test settings. It controls parallel execution and browser options.[3]

14. How do you perform file upload in Playwright?

Use page.setInputFiles('input[type=file]', '/path/to/file.pdf'). Playwright handles this natively without complex workarounds.[2]

15. Explain cross-browser testing in Playwright.

Define multiple projects in config for different browsers. Run npx playwright test to execute tests across Chromium, Firefox, and WebKit.[4]

16. How do you use test tags in Playwright?

Annotate tests with test('scenario @smoke @regression'). Run specific tags using npx playwright test @smoke.[1]

17. What are assertions in Playwright?

Playwright has built-in expect assertions like await expect(page.locator('h1')).toHaveText('Welcome');. Supports soft assertions too.[2]

18. How do you handle frames/iframes in Playwright?

Use page.frameLocator('iframe-selector') or page.frame({ name: 'frameName' }) to interact with elements inside frames.[3]

19. What is shadow DOM handling in Playwright?

Pierce shadow DOM with page.locator('host >> css=shadow-element') using the >> operator.[3]

20. How do you run tests in parallel?

Set workers: process.env.CI ? 1 : undefined in config. Playwright runs tests across workers by default for speed.[1]

Advanced Playwright Interview Questions

21. What are actionability checks in Playwright?

Before actions like click, Playwright checks if element is attached, visible, stable (no animations), enabled, and receives events.[2]

22. How do you mock API responses in Playwright?

await page.route('**/api/users', route => 
  route.fulfill({ status: 200, body: JSON.stringify(mockData) })
);

[3]

23. Explain component testing in Playwright.

Component testing mounts React/Vue/Angular components in isolation using @playwright/experimental-ct-react for faster feedback.[2]

24. How do you handle authentication in Playwright?

Persist storage state with context.storageState({ path: 'auth.json' }). Reuse in tests via config projects for authenticated sessions.[3]

25. What is trace recording in Playwright?

Enable traces with trace: 'on' in config or await context.tracing.start(). View with npx playwright show-trace for debugging.[3]

26. Scenario: At Swiggy, tests fail intermittently on dynamic tables. How to handle?

Use page.locator('table tr').nth(2) or wait for specific row text: await page.locator('text=Order #123').waitFor();[3]

27. How do you test mobile viewports in Playwright?

Set viewport in config: viewport: { width: 375, height: 667 } or emulate device: browser.newContext({ ...devices['iPhone 12'] }).[1]

28. Scenario: For Adobe’s dashboard, handle dropdown with search. Solution?

await page.click('button[aria-haspopup=listbox]');
await page.fill('.dropdown-search', 'option text');
await page.click('.dropdown-option');

[1]

29. Explain API testing in Playwright.

Use request = browser.request.get('/api/endpoint'). Assert status, headers, body: expect(response.status()).toBe(200);[2]

30. How do you integrate Playwright with CI/CD for Oracle projects?

Use GitHub Actions or Jenkins with npx playwright test. Set workers: 1 in CI, enable artifacts for reports and traces.[1]

Leave a Reply

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