playwright
/playwright
Expert Playwright testing assistance covering cross-browser E2E, auto-waiting, visual comparisons, and tracing. Use when automating modern web applications, testing Chromium/Firefox/WebKit, or debugging flakiness.
- Author
- G1Joshi ↗
- Repository
- Agent-Skills ↗
- Licence
- MIT
- Last repository change
- 01.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 2
No signals detected. Repository changed on 01.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Expert Playwright testing assistance covering cross-browser E2E, auto-waiting, visual comparisons, and tracing. Use when automating modern web applications, testing Chromium/Firefox/WebKit, or debugging flakiness.
Original author description
Expert Playwright testing assistance covering cross-browser E2E, auto-waiting, visual comparisons, and tracing. Use when automating modern web applications, testing Chromium/Firefox/WebKit, or debugging flakiness.
How it works
- When to Use
- Quick Start
- Core Concepts
- Common Patterns
- Best Practices
- Troubleshooting
- References
SKILL.md preview
---
name: playwright
description: Expert Playwright testing assistance covering cross-browser E2E, auto-waiting, visual comparisons, and tracing. Use when automating modern web applications, testing Chromium/Firefox/WebKit, or debugging flakiness.
---
# Playwright
Playwright is Microsoft's modern automation library. It enables reliable end-to-end testing for modern web apps across Chromium, WebKit, and Firefox.
## When to Use
- **Modern Web End-to-End Automation**: The industry standard for cross-browser testing across Chromium, WebKit (Safari), and Firefox.
- **Multi-Tab & Multi-Origin Testing**: Testing complex workflows spanning popups, payment gateways, and multiple browser tabs seamlessly.
- **Mobile Emulation & Geolocation**: Simulating iPhone, Pixel, network throttling, and geographic permissions reliably.
- **API Testing Alongside UI**: Sending REST and GraphQL requests directly within tests via `request` context.
## Quick Start
```typescript
import { test, expect } from "@playwright/test";
test.describe("Navigation", () => {
test("should navigate to login", async ({ page }) => {
await page.goto("https://example.com");
await page.getByRole("button", { name: "Log in" }).click();
await expect(page).toHaveURL(/.*login/);
});
});
```
## Core Concepts
### Auto-Waiting & Resilient Locators
Playwright automatically waits for elements to be attached, visible, stable, and receive events before clicking:
```typescript
// tests/checkout.spec.ts
import { test, expect } from "@playwright/test";
test("customer can complete checkout", async ({ page }) => {
await page.goto("/catalog");
// Locates using accessible role and auto-waits
await page.getByRole("button", { name: "Add to Cart" }).first().click();
await page.getByRole("link", { name: "View Cart" }).click();
await expect(page.getByTestId("cart-total")).toHaveText("$49.99");
await page.getByRole("button", { name: "Checkout" }).click();
await expect(page).toHaveURL(/.*checkout\/success/);
});
```
### Trace Viewer for Post-Mortem Debugging
Records DOM snapshots, console logs, network waterfalls, and action videos during test runs:
```bash
# Run tests and record trace on failure
npx playwright test --trace on-first-retry
# View interactive trace viewer
npx playwright show-trace trace.zip
```
### Network Mocking & HAR Replay
Intercepts requests and fulfills them with mock responses:
```typescript
test("displays error banner on API failure", async ({ page }) => {
await page.route("**/api/v1/inventory", (route) => {
route.fulfill({
status: 503,
body: JSON.stringify({ error: "Service Unavailable" }),
});
});
await page.goto("/inventory");
await expect(
page.getByText("Inventory service is currently offline"),
).toBeVisible();
});
```
## Common Patterns
### Page Object Model with Locator Auto-Waiting
**Problem**: Raw selector strings scattered across test files cause maintenance headaches when UI layouts change.
**Solution**:
Encapsulate selectors and actions in Page Objects:
```typescript
import { Page, Locator } from "@playwright/test";
export class LoginPage {
readonly page: Page;
readonly usernameInput: Locator;
readonly passwordInput: Locator;
readonly loginButton: Locator;
constructor(page: Page) {
this.page = page;
this.usernameInput = page.getByLabel("Username");
this.passwordInput = page.getByLabel("Password");
this.loginButton = page.getByRole("button", { name: "Log in" });
}
async login(user: string, pass: string) {
await this.usernameInput.fill(user);
await this.passwordInput.fill(pass);
await this.loginButton.click();
}
}
```
## Best Practices
**Do**:
- Prefer User-Facing Locators: Use `page.getByRole()`, `page.getByText()`, and `page.getByLabel()` over fragile CSS selectors.
- Use Web-First Assertions: Always use `await expect(locator).toBeVisible()` which automatically retries until passing.
- Reuse Storage State for Fast Authentication: Save auth cookies with `storageState` to log in once rather than in every test.
- Run in Parallel Across Browsers: Leverage Playwright's native worker parallelization across Chromium, WebKit, and Firefox.
**Don't**:
- Use `page.waitForTimeout(5000)`: Static delays cause flakiness; wait for locators or network states instead.
- Rely on XPath selectors: XPath selectors break easily when DOM hierarchies shift.
- Share state between tests: Use independent `BrowserContext` instances to ensure zero test cross-contamination.
## Troubleshooting
| Error | Cause | Solution |
| :------------------------------------------------------------- | :--------------------------------------------------------- | :-------------------------------------------------------------------------- |
| `TimeoutError: page.waitForSelector: Timeout 30000ms exceeded` | Target element never entered visible DOM state. | Check selector in Playwright Inspector using `npx playwright test --debug`. |
| `Target closed / browser disconnected` | Container or system ran out of shared memory (`/dev/shm`). | Run container with `--shm-size=2gb` or set `chromiumSandbox: false`. |
| `Strict mode violation: getByRole(...) resolved to 2 elements` | Selector matches more than one visible element. | Disambiguate using `.first()`, index, or more specific locator text. |
## References
- [Playwright Documentation](https://playwright.dev/)
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · G1Joshi/Agent-Skills | 100 | MIT |
| magnus919/agent-skills | 100 | MIT |
| kriscard/kriscard-claude-plugins | 100 | MIT |
| zenobi-us/dotfiles | 100 | MIT |
| dreamlab-ai/agentbox | 100 | AGPL-3.0 |
| DroBov1Tya/dusk_code | 100 | MIT |
| ivy00johns/skill-madness | 100 | MIT |
| musingfox/cc-plugins | 100 | MIT |
| netease-youdao/LobsterAI | 100 | MIT |
Database snapshot: 13.11.2026 · package version 240acd1fa760 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100playwright-testing
Write and maintain end-to-end tests with Playwright. Use when someone asks to "add e2e tests", "test my web app", "set up Playwright", "write browser tests", "test login flow", "visual regression testing", "test across browsers", or "automate UI testing". Covers test setup, page… - 100playwright-end-to-end-browser-automation
Use this skill when automating cross-browser end-to-end web testing, auto-waiting locators, video recordings, and trace inspections. - 98playwright-use-chrome
Configure and enforce Playwright to use the system's installed Google Chrome browser instead of downloading bulky bundled Chromium/WebKit/Firefox binaries (~1.5GB - 2GB). Use whenever writing or configuring Playwright tests, web scraping scripts, browser automation, E2E testing,… - 100e2e-playwright
Use when writing end-to-end browser tests with Playwright. Covers resilient locators, auto-waiting, network interception, authentication reuse, parallelization, and eliminating flakiness. Trigger on "write playwright tests", "e2e test is flaky", "replace our cypress suite",… - 100playwright-testing
Authors and remediates Playwright E2E tests across Chromium, Firefox, WebKit - `npm init playwright@latest` scaffolding, `playwright.config.ts` browser projects, accessibility-first locators (`getByRole`/`getByLabelText`) to replace brittle CSS selectors, web-first assertions to… - 95playwright-e2e-automation
Master enterprise Playwright end-to-end (E2E) automation, Page Object Model (POM) architecture, cross-browser testing, network mocking, visual regression testing, and CI pipeline integrations. Trigger when writing Playwright tests, automating web UI E2E flows, or configuring…