playwright-expert

Write and debug Playwright end-to-end tests using page objects, role-based selectors, and trace analysis.

1|Updated Jul 2, 2026
One-click install
npx skills add https://github.com/filippolmt/skills --skill playwright-expert-filippolmt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: playwright-expert
Source: https://github.com/filippolmt/skills/tree/main/skills/playwright-expert
Command: npx skills add https://github.com/filippolmt/skills --skill playwright-expert-filippolmt

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Writing browser tests that are stable, maintainable, and debuggable is hard: brittle CSS selectors break on refactors, arbitrary timeouts cause flaky failures, and teams lack consistent patterns for page objects, fixtures, and CI integration. ## Core Features & Use Cases - Test Authoring with Best Practices: Generates Playwright tests using role-based selectors, auto-waiting, and the Page Object Model pattern with TypeScript fixtures. - Flaky Test Debugging: Provides a trace-viewer-driven workflow to diagnose race conditions, network timing issues, and shared-state problems, replacing waitForTimeout with proper waits. - Infrastructure Setup: Covers playwright.config.ts configuration, API mocking via route interception, authentication state reuse, multi-browser projects, and GitHub Actions CI integration. - Use Case: When a login flow test fails intermittently in CI, invoke this Skill to capture a trace, identify the race condition, and rewrite the test with proper locator waits verified over repeated runs. ## Quick Start Write a Playwright test suite for my login page using the Page Object Model and role-based selectors, then configure retries and trace capture for CI.

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 authenticated pages and page objects across tests.

How to fix flaky Playwright tests in CI?

Enable trace: 'on-first-retry' in playwright.config.ts, rerun with retries, and inspect the trace viewer timeline. Replace waitForTimeout calls with locator waits like waitFor({ state: 'visible' }) or waitForResponse, then verify stability with --repeat-each=10.

What selectors should I use in Playwright tests?

Prefer getByRole with an accessible name, then getByLabel or getByPlaceholder for forms, and getByTestId for non-semantic elements. Avoid CSS class selectors and XPath because they break when styling or markup changes.

How do I mock API responses in Playwright?

Use page.route with a URL pattern and call route.fulfill to return a mock status and JSON body, or route.fetch to modify real responses. You can also record and replay responses with routeFromHAR for deterministic tests.

Does Playwright support running tests in CI with GitHub Actions?

Yes. Install browsers with npx playwright install --with-deps, run npx playwright test, and upload the playwright-report directory as an artifact. Set retries and a single worker via environment checks on process.env.CI.

Why should I avoid waitForTimeout in Playwright?

waitForTimeout pauses for a fixed duration regardless of actual page state, causing slow or flaky tests. Playwright locators auto-wait for actionability, and explicit waits like toBeVisible or waitForResponse synchronize on real conditions.