Playwright E2E Testing Automation Skill
Automate end-to-end testing with Playwright - the modern browser automation framework that supports Chromium, Firefox, and WebKit with a single API.
Open the source and read safety notes before installing.
Prerequisites
- Node.js 18+
- Playwright 1.40+
- @playwright/test package
- Browser binaries (Chromium, Firefox, WebKit)
- Browser binaries installed via Playwright (npx playwright install) for target browsers (Chromium, Firefox, WebKit)
- Test application or website accessible for testing (local development server, staging environment, or production URL)
Schema details
- Install type
- package
- Reading time
- 6 min
- Difficulty score
- 100
- Troubleshooting
- Yes
- Breaking changes
- No
- Download URL
- /downloads/skills/playwright-e2e-testing.zip
- Package verified
- Yes
- SHA-256
- 61fb431b4e7253846d6c180b34c22226e431cd3234bd5f6917fdf18702df5dbe
- Skill type
- general
- Skill level
- advanced
- Verification
- draft
- Verified at
- 2025-10-16
| Platform | Support | Install path |
|---|---|---|
| claude-code | Native | .claude/skills/<skill-name>/SKILL.md |
| codex | Native | .agents/skills/<skill-name>/SKILL.md |
| windsurf | Native | .windsurf/skills/<skill-name>/SKILL.md |
| gemini | Native | .gemini/skills/<skill-name>/SKILL.md or .agents/skills/<skill-name>/SKILL.md |
| cursor | Adapter | .cursor/rules/<skill-name>.mdc |
| cli | Manual | AGENTS.md or tool-specific context file |
Full copyable content
import { test, expect } from '@playwright/test';
test.describe('Dashboard Tests', () => {
test.beforeEach(async ({ page }) => {
// Login before each test
await page.goto('http://localhost:3000/login');
await page.getByLabel('Email').fill('user@example.com');
await page.getByLabel('Password').fill('password123');
await page.getByRole('button', { name: 'Sign In' }).click();
await page.waitForURL('**/dashboard');
});
test('displays welcome message', async ({ page }) => {
const heading = page.getByRole('heading', { name: /welcome/i });
await expect(heading).toBeVisible();
});
test('loads user profile data', async ({ page }) => {
await page.getByRole('link', { name: 'Profile' }).click();
await expect(page.getByText('user@example.com')).toBeVisible();
});
});About this resource
What This Skill Enables
Claude can write, execute, and maintain end-to-end tests using Playwright, the modern browser automation framework that has overtaken Cypress in npm downloads as of 2025. This skill enables cross-browser testing (Chrome, Firefox, Safari/WebKit), AI-powered test generation with GitHub Copilot integration, and official MCP (Model Context Protocol) support for structured DOM interactions.
Compatibility
Native
- Claude Code / Claude: native skill usage via
SKILL.md. - Codex/OpenAI workflows: compatible with Agent Skills-style
SKILL.mdcontent as reusable workflow instructions.
Manual Adaptation
- Gemini CLI: native skill usage via
.gemini/skills/<skill-name>/SKILL.mdor.agents/skills/<skill-name>/SKILL.mdwhere supported. - Cursor: use the generated
.cursor/rules/*.mdcadapter for project rules. - OpenClaw and similar agents: use the same skill content as a reusable prompt/workflow file when native skill import is unavailable.
Prerequisites
Required:
- Claude Pro subscription or Claude Code CLI
- Node.js 18+ installed
- Basic understanding of your application's user flows
What Claude handles automatically:
- Installing Playwright and browser binaries
- Generating test files with proper TypeScript types
- Setting up test configurations and reporters
- Writing selectors using accessibility snapshots
- Debugging test failures with traces and screenshots
- Optimizing tests for parallel execution
How to Use This Skill
Basic Test Generation
Prompt: "Create a Playwright test that logs into my application at localhost:3000, navigates to /dashboard, and verifies the welcome message appears."
Claude will:
- Install Playwright if not present (
npm init playwright@latest) - Generate a test file with proper page object patterns
- Use accessibility-first selectors (role, label, text)
- Include assertions with auto-retry logic
- Add screenshot capture on failure
AI-Powered Test Creation from User Stories
Prompt: "I have a checkout flow: user adds product to cart, enters shipping info, selects payment method, and completes order. Write comprehensive Playwright tests covering happy path and error cases."
Claude will:
- Break down the user story into discrete test scenarios
- Generate test files organized by feature
- Include data-driven tests with fixtures
- Add network mocking for payment gateway
- Implement custom assertions for order confirmation
- Set up test retry logic for flaky network calls
Cross-Browser Testing Suite
Prompt: "Set up Playwright to test my application across Chrome, Firefox, and Safari with parallel execution. Include mobile viewport testing for iOS and Android."
Claude will:
- Configure
playwright.config.tswith multiple projects - Define desktop and mobile browser contexts
- Set up parallel worker configuration
- Configure test sharding for CI/CD
- Add HTML reporter with trace viewer
- Include screenshot comparison for visual regression
API Testing Integration
Prompt: "Write Playwright tests that verify my REST API endpoints before running UI tests. Mock the API responses for offline testing."
Claude will:
- Use Playwright's
requestcontext for API calls - Create API test fixtures for reusable setup
- Implement request/response interception
- Generate mock data with realistic values
- Set up contract testing with schema validation
- Add performance timing assertions
Tips for Best Results
Use Accessibility Selectors: Playwright's MCP support leverages accessibility snapshots. Ask Claude to use
getByRole(),getByLabel(), andgetByText()instead of CSS selectors for more resilient tests.Parallel Execution: Playwright's native parallelism is a key advantage. Request test organization that maximizes parallel worker usage with proper test isolation.
Auto-Wait Smart Defaults: Playwright automatically waits for elements to be actionable. Avoid explicit waits unless dealing with specific timing requirements.
Trace on Failure: Enable trace recording for CI environments to debug failures without reproducing locally:
--trace on-first-retry.Codegen for Complex Flows: For intricate user interactions, ask Claude to generate tests using
npx playwright codegenoutput as a starting point.Test Sharding: For large test suites in CI, request sharding configuration:
--shard=1/4to split tests across multiple jobs.
Common Workflows
Complete E2E Test Suite Setup
"Set up a production-ready Playwright test suite for my Next.js app with:
1. Authentication flow tests with session storage
2. Visual regression testing with screenshot comparison
3. API mocking for external services
4. CI/CD integration with GitHub Actions
5. HTML report with trace viewer
6. Parallel execution across 4 workers"
AI-Assisted Test Maintenance
"My application's login form changed from using email to username.
Update all Playwright tests that interact with the login form,
using accessibility selectors instead of data-testid attributes."
Performance Testing
"Write Playwright tests that measure:
1. First Contentful Paint (FCP)
2. Largest Contentful Paint (LCP)
3. Time to Interactive (TTI)
4. Total Blocking Time (TBT)
Fail tests if any metric exceeds Web Vitals thresholds."
Mobile-First Testing
"Create Playwright tests for mobile web experience:
1. Test on iPhone 13 and Pixel 5 viewports
2. Verify touch interactions (swipe, pinch-to-zoom)
3. Test offline mode with service worker
4. Validate responsive image loading
5. Check mobile-specific navigation menu"
Troubleshooting
Issue: Tests are flaky and fail intermittently
Solution: Ask Claude to add explicit waitForLoadState('networkidle') calls, increase timeout for specific actions with { timeout: 10000 }, or implement custom wait conditions with page.waitForFunction().
Issue: Selectors break when UI changes
Solution: Request migration to accessibility selectors (getByRole, getByLabel) which are more resilient to DOM structure changes. Playwright's MCP integration makes this the preferred approach.
Issue: Tests run too slowly in CI Solution: Ask Claude to implement test sharding across multiple GitHub Actions jobs, optimize test setup with global authentication fixtures, and enable trace recording only on failure.
Issue: Cannot test third-party authentication (OAuth, SSO)
Solution: Request implementation of authentication state storage with storageState option, bypassing the login flow for most tests while keeping one dedicated authentication test.
Issue: Screenshot comparison fails due to font rendering differences
Solution: Ask Claude to configure Playwright's maxDiffPixels or threshold options, or use textual assertions instead of visual regression for text-heavy areas.
Learn More
- Playwright Official Documentation
- Playwright MCP Integration Guide
- Playwright vs Cypress 2025 Comparison
- AI-Powered Testing with Playwright
- Playwright Test Best Practices
Features
- Cross-browser testing: Chrome, Firefox, Safari (WebKit) with single API
- AI-powered test generation with GitHub Copilot and codegen
- MCP support for accessibility-driven interactions (getByRole, getByLabel, getByText)
- Native parallel execution and test sharding for CI/CD
- Visual regression testing with screenshot comparison and pixel diff
- API testing and contract validation with request context
- Network request interception and mocking for offline testing
- Trace viewer with screenshots, snapshots, and sources for debugging
Use Cases
- End-to-end testing for web applications with cross-browser coverage
- Visual regression testing with screenshot comparison and pixel diff
- API testing and contract validation with request context
- Mobile web testing with device emulation (iPhone, Pixel, etc.)
- Performance testing with Web Vitals metrics (FCP, LCP, TTI, TBT)
- Accessibility testing with screen reader automation and ARIA validation
- What This Skill Enables
- Compatibility
- Native
- Manual Adaptation
- Prerequisites
- How to Use This Skill
- Basic Test Generation
- AI-Powered Test Creation from User Stories
- Cross-Browser Testing Suite
- API Testing Integration
- Tips for Best Results
- Common Workflows
- Complete E2E Test Suite Setup
- AI-Assisted Test Maintenance
- Performance Testing
- Mobile-First Testing
Source citations
Signals
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.