playwrightlisted
Install: claude install-skill DROOdotFOO/agent-skills
# Playwright Skill
Browser automation and end-to-end testing with Playwright. Covers both Python (pytest-playwright) and TypeScript (@playwright/test).
## Core Principles
- **Auto-waiting by default** -- Playwright waits for elements to be actionable before interacting. Do not add manual sleeps.
- **Test isolation** -- Every test gets a fresh browser context. Do not share state between tests.
- **User-facing selectors** -- Prefer `getByRole`, `getByText`, `getByLabel` over CSS/XPath. These are resilient to DOM changes.
- **Web-first assertions** -- Use Playwright's built-in assertions that auto-retry, not raw `assert` or `expect` from other libraries.
## Quick Reference
### Python Setup
```bash
pip install pytest-playwright
playwright install
```
### TypeScript Setup
```bash
npm init playwright@latest
# or
npx playwright install
```
### Run Tests
```bash
# Python
pytest --headed # visible browser
pytest --browser firefox # specific browser
pytest -k "test_login" # filter by name
# TypeScript
npx playwright test # all tests
npx playwright test --ui # interactive UI mode
npx playwright test --debug # step-through debugger
npx playwright test login.spec # specific file
```
## WRONG vs CORRECT: Selector Strategy
### WRONG -- brittle CSS selectors
```python
# WRONG: tightly coupled to DOM structure
page.click("div.header > ul.nav > li:nth-child(3) > a")
page.fill("input#email-field-v2", "user@example.com"