playwright-skill
Skill387 starsChanged 3 days agoMITView on GitHub
Generates production-grade Playwright automation scripts and E2E tests in TypeScript, JavaScript, Python, Java, or C#. Supports local execution and TestMu AI cloud across 3000+ browser/OS combinations and real mobile devices. Use when the user asks to write Playwright tests, automate browsers, run cross-browser tests, test on real devices, debug flaky tests, mock APIs, or do visual regression. Triggers on: "Playwright", "E2E test", "browser test", "run on cloud", "cross-browser", "TestMu", "LambdaTest", "test my app", "test on mobile", "real device".
- Reads credentials
We split this skill into the rules it gives an agent
4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 23 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 67
Use in this order — stop at the first that works:
- Distinctive: line 75
Never use raw CSS/XPath unless matching a third-party widget with no other option.
- Distinctive: line 103
Use POM for any project with more than 3 tests.
- Distinctive: line 230
After generating any test:
“Common” is measured: kept by at least 6 in 10 of the 23 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Playwright Test Automation
Step 1 — Determine Execution Target
Decide BEFORE writing any code:
| User says... | Target | Action |
| No cloud mention, "locally", "debug" | Local | Standard Playwright config |
| "cloud", "TestMu", "LambdaTest", "cross-browser", "real device" | Cloud | See reference/cloud-integration.md |
| Impossible local combo (Safari on Windows, Edge on Linux) | Cloud | Suggest TestMu AI, see reference/cloud-integration.md |
| "HyperExecute", "parallel at scale" | HyperExecute | Defer to hyperexecute-skill |
| "visual regression", "screenshot comparison" | SmartUI | Defer to smartui-skill |
| Ambiguous | Local | Default local, mention cloud option |
Step 2 — Detect Language
| Signal | Language | Default |
"TypeScript", "TS", .ts, or no language specified | TypeScript | ✅ |
"JavaScript", "JS", .js | JavaScript | |
"Python", "pytest", .py | Python | See reference/python-patterns.md |
| "Java", "Maven", "Gradle", "TestNG" | Java | See reference/java-patterns.md |
| "C#", ".NET", "NUnit", "MSTest" | C# | See reference/csharp-patterns.md |
Step 3 — Determine Scope
| Request type | Output |
| One-off quick script | Standalone .ts file, no POM |
| Single test for existing project | Match their structure and conventions |
| New test suite / project | Full scaffold — see scripts/scaffold-project.sh |
| Fix flaky test | Debugging checklist — see reference/debugging-flaky.md |
| API mocking needed | See reference/api-mocking-visual.md |
| Mobile device testing | See reference/mobile-testing.md |
Core Patterns — TypeScript (Default)
Selector Priority
Use in this order — stop at the first that works:
getByRole('button', { name: 'Submit' })— accessible, resilientgetByLabel('Email')— form fieldsgetByPlaceholder('Enter email')— when label missinggetByText('Welcome')— visible textgetByTestId('submit-btn')— last resort, needsdata-testid
Never use raw CSS/XPath unless matching a third-party widget with no other option.
Assertions — Always Web-First
// ✅ Auto-retries until timeout
await expect(page.getByRole('heading')).toBeVisible();
await expect(page.getByRole('alert')).toHaveText('Saved');
await expect(page).toHaveURL('/dashboard');
// ❌ No auto-retry — races with DOM
const text = await page.textContent('.msg');
expect(text).toBe('Saved');Anti-Patterns
| ❌ Don't | ✅ Do | Why |
page.waitForTimeout(3000) | await expect(locator).toBeVisible() | Hard waits are flaky |
expect(await el.isVisible()) | await expect(el).toBeVisible() | No auto-retry |
page.$('.btn') | page.getByRole('button') | Fragile selector |
page.click('.submit') | page.getByRole('button', {name:'Submit'}).click() | Not accessible |
| Shared state between tests | test.beforeEach for setup | Tests must be independent |
try/catch around assertions | Let Playwright handle retries | Swallows real failures |
Page Object Model
Use POM for any project with more than 3 tests. Full patterns with base page, fixtures, and examples in reference/page-object-model.md.
Quick example:
// pages/login.page.ts
import { Page, Locator } from '@playwright/test';
export class LoginPage {
readonly emailInput: Locator;
readonly passwordInput: Locator;
readonly submitButton: Locator;
constructor(private page: Page) {
this.emailInput = page.getByLabel('Email');
this.passwordInput = page.getByLabel('Password');
this.submitButton = page.getByRole('button', { name: 'Sign in' });
}
async login(email: string, password: string) {
await this.emailInput.fill(email);
await this.passwordInput.fill(password);
await this.submitButton.click();
}
}Configuration — Local
// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: './tests',
timeout: 30_000,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [['html'], ['list']],
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
},
projects: [
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
{ name: 'webkit', use: { ...devices['Desktop Safari'] } },
{ name: 'mobile-chrome', use: { ...devices['Pixel 5'] } },
{ name: 'mobile-safari', use: { ...devices['iPhone 13'] } },
],
webServer: {
command: 'npm run dev',
port: 3000,
reuseExistingServer: !process.env.CI,
},
});Cloud Execution on TestMu AI
Set environment variables: LT_USERNAME, LT_ACCESS_KEY
Direct CDP connection (standard approach):
// lambdatest-setup.ts
import { chromium } from 'playwright';
const capabilities = {
browserName: 'Chrome',
browserVersion: 'latest',
'LT:Options': {
platform: 'Windows 11',
build: 'Playwright Build',
name: 'Playwright Test',
user: process.env.LT_USERNAME,
accessKey: process.env.LT_ACCESS_KEY,
network: true,
video: true,
console: true,
},
};
const browser = await chromium.connect({
wsEndpoint: `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`,
});
const context = await browser.newContext();
const page = await context.newPage();HyperExecute project approach (for parallel cloud runs):
// Add to projects array in playwright.config.ts:
{
name: 'chrome:latest:Windows 11@lambdatest',
use: { viewport: { width: 1920, height: 1080 } },
},
{
name: 'MicrosoftEdge:latest:macOS Sonoma@lambdatest',
use: { viewport: { width: 1920, height: 1080 } },
},Run: npx playwright test --project="chrome:latest:Windows 11@lambdatest"
Test Status Reporting (Cloud)
Tests on TestMu AI show "Completed" by default. You MUST report pass/fail:
// In afterEach or test teardown:
await page.evaluate((_) => {},
`lambdatest_action: ${JSON.stringify({
action: 'setTestStatus',
arguments: { status: testInfo.status, remark: testInfo.error?.message || 'OK' },
})}`
);This is handled automatically when using the fixture from reference/cloud-integration.md.
Validation Workflow
After generating any test:
1. Validate config: python scripts/validate-config.py playwright.config.ts
2. If errors → fix → re-validate
3. Run locally: npx playwright test --project=chromium
4. If cloud: npx playwright test --project="chrome:latest:Windows 11@lambdatest"
5. If failures → check reference/debugging-flaky.mdQuick Reference
Common Commands
npx playwright test # Run all tests
npx playwright test --ui # Interactive UI mode
npx playwright test --debug # Step-through debugger
npx playwright test --project=chromium # Single browser
npx playwright test tests/login.spec.ts # Single file
npx playwright show-report # Open HTML report
npx playwright codegen https://example.com # Record test
npx playwright test --update-snapshots # Update visual baselinesAuth State Reuse
// Save auth state once in global setup
await page.context().storageState({ path: 'auth.json' });
// Reuse in config
use: { storageState: 'auth.json' }Visual Regression (Built-in)
await expect(page).toHaveScreenshot('homepage.png', {
maxDiffPixelRatio: 0.01,
animations: 'disabled',
mask: [page.locator('.dynamic-date')],
});Network Mocking
await page.route('**/api/users', (route) =>
route.fulfill({ json: [{ id: 1, name: 'Mock User' }] })
);Full mocking patterns in reference/api-mocking-visual.md.
Test Steps for Readability
test('checkout flow', async ({ page }) => {
await test.step('Add item to cart', async () => {
await page.goto('/products');
await page.getByRole('button', { name: 'Add to cart' }).click();
});
await test.step('Complete checkout', async () => {
await page.getByRole('link', { name: 'Cart' }).click();
await page.getByRole('button', { name: 'Checkout' }).click();
});
});Reference Files
| File | When to read |
| reference/cloud-integration.md | Cloud execution, 3 integration patterns, parallel browsers |
| reference/page-object-model.md | POM architecture, base page, fixtures, full examples |
| reference/mobile-testing.md | Android + iOS real device testing |
| reference/debugging-flaky.md | Flaky test checklist, common fixes |
| reference/api-mocking-visual.md | API mocking + visual regression patterns |
| reference/python-patterns.md | Python-specific: pytest-playwright, sync/async |
| reference/java-patterns.md | Java-specific: Maven, JUnit, Gradle |
| reference/csharp-patterns.md | C#-specific: NUnit, MSTest, .NET config |
| ../shared/testmu-cloud-reference.md | Full device catalog, capabilities, geo-location |
Advanced Playbook
For production-grade patterns, see reference/playbook.md:
| Section | What's Inside |
| §1 Production Config | Multi-project, reporters, retries, webServer |
| §2 Auth Fixture Reuse | storageState, multi-role fixtures |
| §3 Page Object Model | BasePage, LoginPage with fluent API |
| §4 Network Interception | Mock, modify, HAR replay, block resources |
| §5 Visual Regression | Screenshot comparison, masks, thresholds |
| §6 File Upload/Download | fileChooser, setInputFiles, download events |
| §7 Multi-Tab & Dialogs | Popup handling, alert/confirm/prompt |
| §8 Geolocation & Emulation | Location, timezone, locale, color scheme |
| §9 Custom Fixtures | DB seeding, API context, auto-teardown |
| §10 API Testing | Request context, end-to-end API+UI |
| §11 Accessibility | axe-core integration, WCAG audits |
| §12 Sharding | CI matrix sharding, report merging |
| §13 CI/CD | GitHub Actions with artifacts |
| §14 Debugging Toolkit | Debug, UI mode, trace viewer, codegen |
| §15 Debugging Table | 10 common problems with fixes |
| §16 Best Practices | 17-item production checklist |
Other versions27 projects use a version of this.
Word for word · 2
- noahsilve123/claude-skillset★ 1100% same
- Bot2353/skills★ 0100% same
Edited · 0
None found.
Wrote their own version · 25
- zebbern/claude-code-guide★ 4.7ksame name
- mercurjs/mercur★ 1.9ksame name
- testdino-hq/playwright-skill★ 393same name
- appautomaton/webmaton★ 20same name
- DangQuangSE/team-development-skills★ 19same name
- idanbeck/claude-skills★ 14same name
- xfstudio/skills★ 9same name
- TheArchitectit/awesome-cline-skills★ 8same name
- tstapler/dotfiles★ 8same name
- appautomaton/playwright-skill★ 6same name
15 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use playwright-ci, playwright-migration and 8 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
zebbernSkillplaywright-ci
Production-ready CI/CD configurations for Playwright — GitHub Actions, GitLab CI, CircleCI, Azure DevOps, Jenkins, Docker, parallel sharding, reporting, code coverage, and global setup/teardown.
Also in 3 projects that use this
zebbernSkillplaywright-migration
Step-by-step migration guides for moving to Playwright from Cypress or Selenium/WebDriver — command mappings, architecture changes, and incremental adoption strategies.
Also in 3 projects that use this
MicrosoftSkillplaywright-cli
Automate browser interactions, test web pages and work with Playwright tests.
Also in 5 projects that use this
OpenAISkillbrainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.
Also in 5 projects that use this
AnthropicSkillpdf
Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.
Also in 5 projects that use this
OpenAISkillusing-git-worktrees
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback
Also in 3 projects that use this
- +1 more from zebbern
- +1 more from openai
In this repository49 other files it gives its agents.
- accessibility-skillSkill
- appium-skillSkill
- behat-skillSkill
- behave-skillSkill
- capybara-skillSkill
- cicd-pipeline-skillSkill
- codeception-skillSkill
- cucumber-skillSkill
- cypress-skillSkill
- detox-skillSkill
- espresso-skillSkill
- flutter-testing-skillSkill
- gauge-skillSkill
- geb-skillSkill
- hyperexecute-skillSkill
- jasmine-skillSkill
- jest-skillSkill
- junit-5-skillSkill
- kanecli-skillSkill
- karma-skillSkill
- laravel-dusk-skillSkill
- lettuce-skillSkill
- mocha-skillSkill
- mstest-skillSkill
- nemojs-skillSkill
- nightwatchjs-skillSkill
- nunit-skillSkill
- phpunit-skillSkill
- protractor-skillSkill
- puppeteer-skillSkill
- pytest-skillSkill
- reqnroll-skillSkill
- robot-framework-skillSkill
- rook-skillSkill
- rspec-skillSkill
- selenide-skillSkill
- selenium-skillSkill
- serenity-bdd-skillSkill
- smartui-skillSkill
- specflow-skillSkill
- testcafe-skillSkill
- test-framework-migration-skillSkill
- testng-skillSkill
- testunit-skillSkill
- unittest-skillSkill
- vitest-skillSkill
- webdriverio-skillSkill
- xcuitest-skillSkill
- xunit-skillSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

