Playwright E2E Testing
Playwright end-to-end testing patterns including page object models, test scenarios, visual regression, and CI/CD integration. Use when building E2E tests, testing web applications, automating browser interactions, implementing page objects, running Playwright tests, debugging E2E failures, or when user mentions Playwright, E2E, browser automation, page object model, POM, visual regression, or end-to-end testing.
What this skill does
# Playwright E2E Testing
**CRITICAL: The description field above controls when Claude auto-loads this skill.**
## Overview
Provides comprehensive Playwright end-to-end testing patterns including:
- Page Object Model (POM) implementation
- Test scenario scaffolding
- Visual regression testing
- CI/CD integration workflows
- Debugging techniques
- Browser automation patterns
## Instructions
### 1. Initialize Playwright Project
Use `scripts/init-playwright.sh` to set up a new Playwright project:
```bash
bash scripts/init-playwright.sh [project-path]
```
This will:
- Install Playwright dependencies
- Create playwright.config.ts from template
- Set up test directory structure
- Install browsers
- Create initial test examples
### 2. Generate Page Object Models
Use `scripts/generate-pom.sh` to create Page Object Model classes:
```bash
bash scripts/generate-pom.sh <page-name> <url> [output-dir]
```
This will:
- Create page object class with base structure
- Add common locators and methods
- Generate TypeScript interface
- Include usage examples
### 3. Run Playwright Tests
Use `scripts/run-playwright.sh` to execute tests:
```bash
bash scripts/run-playwright.sh [test-pattern] [browser] [options]
```
Options:
- Test pattern: Specific test file or glob pattern
- Browser: chromium, firefox, webkit, or all
- Options: --headed, --debug, --trace, --ui
### 4. Debug Test Failures
Use `scripts/debug-playwright.sh` for debugging:
```bash
bash scripts/debug-playwright.sh <test-file>
```
This will:
- Run test in headed mode with slowMo
- Enable trace recording
- Open Playwright Inspector
- Generate debug screenshots
### 5. Visual Regression Testing
Use `scripts/run-visual-regression.sh` for visual testing:
```bash
bash scripts/run-visual-regression.sh [test-pattern] [update-snapshots]
```
This will:
- Run visual regression tests
- Compare against baseline snapshots
- Generate diff images for failures
- Update snapshots if requested
## Available Scripts
- **init-playwright.sh**: Initialize Playwright project with configuration
- **run-playwright.sh**: Execute Playwright tests with various options
- **generate-pom.sh**: Generate Page Object Model classes
- **debug-playwright.sh**: Run tests in debug mode with inspector
- **run-visual-regression.sh**: Execute visual regression tests
## Templates
### Configuration
- **playwright.config.ts**: Comprehensive Playwright configuration with multiple browsers, reporters, and settings
### Page Objects
- **page-object-basic.ts**: Basic Page Object Model template
- **page-object-advanced.ts**: Advanced POM with complex interactions and waiting strategies
### Test Scenarios
- **e2e-test-login.spec.ts**: Login flow E2E test with authentication
- **e2e-test-form.spec.ts**: Form submission and validation test
- **visual-regression.spec.ts**: Visual regression testing example
## Examples
- **basic-usage.md**: Simple Playwright setup and first test
- **page-object-pattern.md**: Implementing Page Object Model pattern
- **visual-regression-testing.md**: Setting up visual regression tests
- **ci-cd-integration.md**: Configuring Playwright in CI/CD pipelines
- **debugging-techniques.md**: Debugging failing E2E tests
## Page Object Model Pattern
### Structure
```typescript
class PageName {
readonly page: Page;
readonly locators: { /* selectors */ };
constructor(page: Page) { /* ... */ }
async navigateTo() { /* ... */ }
async performAction() { /* ... */ }
async verifyState() { /* ... */ }
}
```
### Benefits
- Separation of concerns (test logic vs page structure)
- Reusability across multiple tests
- Easier maintenance when UI changes
- Clear test readability
## Best Practices
### Test Organization
- Use Page Object Model for maintainability
- Group related tests in describe blocks
- Keep tests independent and isolated
- Use beforeEach for common setup
### Selectors
- Prefer data-testid attributes
- Use accessible roles when possible
- Avoid fragile CSS selectors
- Document selector strategies
### Waiting Strategies
- Use auto-waiting (built-in)
- Explicit waits for dynamic content
- waitForLoadState for navigation
- waitForSelector for element visibility
### Visual Regression
- Create stable baseline snapshots
- Use consistent viewport sizes
- Mask dynamic content (dates, random IDs)
- Update snapshots carefully
### CI/CD Integration
- Run in headless mode
- Parallelize tests across workers
- Generate HTML reports
- Upload trace files on failure
- Cache browser binaries
## Debugging Tips
### Playwright Inspector
- Set PWDEBUG=1 environment variable
- Use page.pause() in test code
- Step through actions
- Inspect element locators
### Trace Viewer
- Enable trace: 'on-first-retry'
- View network activity
- Inspect console logs
- Review screenshots and video
### Screenshots and Videos
- Take screenshots on failure
- Record videos for flaky tests
- Use fullPage screenshots
- Compare visual differences
## Requirements
- Node.js 18+ installed
- Playwright 1.40+ recommended
- TypeScript for type safety
- Test files use .spec.ts extension
- Page objects in separate files/directories
- Clear naming conventions for tests and page objects
Related in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.