> 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 "E2E test", "browser test", "run on cloud", "cross-browser", "TestMu", "LambdaTest", "test my app", "test on mobile", "real device".
npx skills add https://github.com/LambdaTest/agent-skills --skill playwright-skill
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 |
| 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 |
| 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 |
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, needs data-testidNever use raw CSS/XPath unless matching a third-party widget with no other option.
// ✅ 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');
| ❌ 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 |
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();
}
}
// 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,
},
});
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"
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.
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.md
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 baselines
// Save auth state once in global setup
await page.context().storageState({ path: 'auth.json' });
// Reuse in config
use: { storageState: 'auth.json' }
await expect(page).toHaveScreenshot('homepage.png', {
maxDiffPixelRatio: 0.01,
animations: 'disabled',
mask: [page.locator('.dynamic-date')],
});
await page.route('**/api/users', (route) =>
route.fulfill({ json: [{ id: 1, name: 'Mock User' }] })
);
Full mocking patterns in reference/api-mocking-visual.md.
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();
});
});
| 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 |
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 |
Execute Python code in a safe sandboxed environment via [inference.sh](https://inference.sh). Pre-installed: NumPy, Pandas, Matplotlib, requests, BeautifulSoup, Selenium, Playwright, MoviePy, Pillow, OpenCV, trimesh, and 100+ more libraries. Use for: data processing, web scraping, image manipulation, video creation, 3D model processing, PDF generation, API calls, automation scripts. Triggers: python, execute code, run script, web scraping, data analysis, image processing, video editing, 3D models, automation, pandas, matplotlib
Execute Python code in a safe sandboxed environment via [inference.sh](https://inference.sh). Pre-installed: NumPy, Pandas, Matplotlib, requests, BeautifulSoup, Selenium, Playwright, MoviePy, Pillow, OpenCV, trimesh, and 100+ more libraries. Use for: data processing, web scraping, image manipulation, video creation, 3D model processing, PDF generation, API calls, automation scripts. Triggers: python, execute code, run script, web scraping, data analysis, image processing, video editing, 3D models, automation, pandas, matplotlib
Upgrade browser versions (Chrome or Firefox) in the Flutter Web Engine and/or Framework tests. Use when asked to roll or upgrade Chrome or Firefox to a newer version.
Migrate PowerToys module UI tests from the legacy WinAppDriver/Selenium harness (Microsoft.PowerToys.UITest) to the new winappcli-based harness (Microsoft.PowerToys.UITest.Next). Use when asked to port/convert/rewrite/modernize a module's UI tests to the .Next framework, create a new [Module].UITests.Next project alongside existing legacy tests, or stand up brand-new winappcli UI tests for a module that has none by reading its human test sign-off markdown. Covers the API mapping (By/Element/Session/UITestBase, KeyboardHelper/MouseHelper/ClipboardHelper), project/csproj scaffolding, naming rules, common PowerToys test recipes (toggle a module, read an activation shortcut, fire a global hotkey, inspect the clipboard, discover overlay/editor windows), build/run validation, and CI-stability hardening for fewer CI iterations. Keywords: UI test, UITests, UITestAutomation.Next, winappcli, WinAppDriver, Selenium, migrate, port, modernize, .Next, MSTest, CI stability, flaky test, stabilize on CI.
> Documentation reference for writing Python code using the browser-use open-source library. Use this skill whenever the user needs help with Agent, Browser, or Tools configuration, is writing code that imports from browser_use, asks about @sandbox deployment, supported LLM models, Actor API, custom tools, lifecycle hooks, MCP server setup, or monitoring/observability with Laminar or OpenLIT. Also trigger for questions about browser-use installation, prompting strategies, or sensitive data handling. Do NOT use this for Cloud API/SDK usage or pricing — use the cloud skill instead. Do NOT use this for directly automating a browser via CLI commands — use the browser-use skill instead.
Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include "Vercel Sandbox browser", "microVM Chrome", "agent-browser in sandbox", "browser automation on Vercel", or any task requiring Chrome in a Vercel Sandbox.
Use the browse CLI for Browserbase browser automation, Browserbase cloud APIs, Browserbase Functions, templates, web fetch/search, diagnostics, and Browse.sh skill discovery/installation. Use when the user asks to navigate pages, inspect browser state, run local or remote browser sessions, manage Browserbase resources, call Browserbase Functions, browse or scaffold Browserbase templates, fetch or search web content, diagnose browse setup, find or install a skill for a website task, discover site-specific Browse.sh skills, or install/refresh this browse skill.
Development workflows for the playwright-cli repository. Use when the user asks about rolling dependencies, releasing, or other repo maintenance tasks.
Take lambdatest/playwright-skill from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference npx.
Without those the skill loads but fails at the first command.