playwright-skill
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 c
By lambdatest · 455 installs
npx skills add lambdatest/agent-skills --skill playwright-skill
Source repository · Upstream listing
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](reference/cloud integration.md)
Impossible local combo (Safari on Windows, Edge on Linux) Cloud Suggest TestMu AI, see [reference/cloud integration.md](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](reference/python patterns.md)
"Java", "Maven", "Gradle", "TestNG" Java See [reference/java patterns.md](reference/java patterns.md)
"C ", ".NET", "NUnit", "MSTest" C See [reference/csharp patterns.md](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](scripts/scaffold project.sh)
Fix flaky test Debugging checklist — see [reference/debugging flaky.md](reference/debugging flaky.md)
API mocking needed See [reference/api mocking visual.md](reference/api mocking visual.md)
Mobile device testing See [reference/mobile testing.md](reference/mobile testing.md)
Core Patterns — TypeScript (Default)
Selector Priority
Use in this order — stop at the first that works:
1. getByRole('button', { name: 'Submit' }) — accessible, resilient
2. getByLabel('Email') — form fields
3. getByPlaceholder('Enter email') — when label missing
4. getByText('Welcome') — visible text
5. getByTestId('submit btn') — last resort, needs data testid
Never use raw CSS/XPath unless matching a third party widget with no other option.
Assertions — Always Web First
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](reference/page object model.md).
Quick example:
Configuration — Local
Cloud Execution on TestMu AI
Set environment variables: LT USERNAME , LT ACCESS KEY
Direct CDP connection (standard approach):
HyperExecute project approach (for parallel cloud runs):
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:
This is handled automatically when using the fixture from [reference/cloud integration.md](reference/cloud integration.md).
Validation Workflow
After generating any test:
Quick Reference
Common Commands
Auth State Reuse
Visual Regression (Built in)
Network Mocking
Full mocking patterns in [reference/api mocking visual.md](reference/api mocking visual.md).
Test Steps for Readability
Reference Files
File When to read
[reference/cloud integration.md](reference/cloud integration.md) Cloud execution, 3 integration patterns, parallel browsers
[reference/page object model.md](reference/page object model.md) POM architecture, base page, fixtures, full examples
[reference/mobile testing.md](reference/mobile testing.md) Android + iOS real device testing
[reference/debugging flaky.md](reference/debugging flaky.md) Flaky test checklist, common fixes
[reference/api mocking visual.md](reference/api mocking visual.md) API mocking + visual regression patterns
[reference/python patterns.md](reference/python patterns.md) Python specific: pytest playwright, sync/async
[reference/java patterns.md](reference/java patterns.md) Java specific: Maven, JUnit, Gradle
[reference/csharp patterns.md](reference/csharp patterns.md) C specific: NUnit, MSTest, .NET config
[../shared/testmu cloud reference.md](../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