playwright-expert

Writes and debugs Playwright end-to-end tests using page objects, locators, and API mocking.

1|Updated Aug 18, 2026
One-click install
npx skills add https://github.com/scsm-unrestrict/dsh-frontend-engineer-agent --skill playwright-expert-scsm-unrestrict
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: playwright-expert
Source: https://github.com/scsm-unrestrict/dsh-frontend-engineer-agent/tree/main/frontend-engineer/skills/playwright-expert
Command: npx skills add https://github.com/scsm-unrestrict/dsh-frontend-engineer-agent --skill playwright-expert-scsm-unrestrict

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @playwright/test, and includes references (resource) components.

What problem does it solve? End-to-end browser tests are often brittle, flaky, and hard to maintain because of poor selectors, arbitrary timeouts, and shared state between tests. This Skill provides structured guidance for writing robust Playwright tests, debugging flaky behavior, and integrating tests into CI pipelines. ## Core Features & Use Cases - Test Authoring with Best Practices: Enforces role-based selectors, auto-waiting, and the Page Object Model pattern with custom fixtures for maintainable test suites. - Flaky Test Debugging: Provides a trace-viewer-driven workflow to diagnose race conditions, animation timing, and network issues, replacing arbitrary waits with proper state assertions. - API Mocking & CI Integration: Covers route interception, HAR-based mocking, authentication state reuse, multi-browser projects, and GitHub Actions configuration. - Use Case: When a login flow test fails intermittently in CI, use this Skill to capture a trace, identify the race condition, replace the brittle CSS selector with a role-based locator, and verify stability by repeating the test ten times. ## Quick Start Ask the agent to write a Playwright test suite for your login page using the Page Object Model with role-based selectors and CI-ready configuration.

Frequently Asked Questions about playwright-expert

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write Playwright tests with the Page Object Model?

Create a class per page that exposes locators as readonly properties and actions as methods, then instantiate it in tests with the page fixture. Combine with custom fixtures via test.extend to share page objects and authenticated state across tests.

What are the best selectors to use in Playwright tests?

Role-based selectors like getByRole are the most resilient, followed by getByLabel, getByPlaceholder, and getByTestId. Avoid CSS class selectors and XPath because they break when styling or markup changes.

How do I fix flaky Playwright tests?

Enable traces with trace: 'on-first-retry', rerun with retries, and inspect the timeline in the trace viewer. Replace waitForTimeout with proper waits like waitForResponse or locator state assertions, and ensure tests are fully isolated.

How do I mock API responses in Playwright?

Use page.route to intercept requests and call route.fulfill with a custom status and JSON body, or route.fetch to modify real responses. You can also record and replay network traffic with routeFromHAR.

Can Playwright tests run in CI with GitHub Actions?

Yes. Install browsers with npx playwright install --with-deps, run npx playwright test, and upload the HTML report as an artifact. Set retries and a single worker in CI via environment-variable checks in playwright.config.ts.

Why should I avoid waitForTimeout in Playwright?

waitForTimeout introduces arbitrary delays that either slow tests or still fail under load. Playwright's auto-waiting locators and explicit waits like waitForURL, waitForResponse, and toBeVisible synchronize on actual application state instead.