mcpField
P
playwright

playwright

github.com/ariadossTesting & quality1266 installsUpdated 1d ago
Repository

About playwright

playwright is a skill for generating and running Playwright end-to-end tests for web applications. It guides test creation around existing project patterns and covers debugging through traces, screenshots, and interactive inspection.

Key features

  1. 01Analyze pages and expected behavior
  2. 02Generate tests matching project patterns
  3. 03Run tests in headed or UI mode
  4. 04Debug with traces and screenshots
  5. 05Test visual output and accessibility

Use cases

  1. 01Testing web navigation and form flows
  2. 02Checking visual changes with screenshot assertions
  3. 03Investigating failures using traces
  4. 04Validating keyboard navigation and ARIA roles

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/ariadoss/superskills --skill playwright

After installing, type/playwrightin Claude Code to confirm it loaded.

Details

From the project README

Playwright E2E Testing

Generate and run Playwright end-to-end tests for web applications.

Prerequisites

npx playwright --version

If not installed:

npm init playwright@latest
# or add to existing project:
npm install -D @playwright/test && npx playwright install

Workflow

1. Analyze

Read the source files for the page/component to test. Understand routes, interactive elements, and expected behaviors.

2. Generate Test File

Create a test file following the project's existing patterns and directory structure.

import { test, expect } from '@playwright/test';

test.describe('Feature Name', () => {
  test.beforeEach(async ({ page }) => {
    // Setup: navigate, authenticate, seed data
  });

  test('should do expected behavior', async ({ page }) => {
    // Arrange
    // Act
    // Assert
  });
});
3. Run Tests
npx playwright test <file>           # Run specific test file
npx playwright test --headed          # With visible browser
npx playwright test --ui              # Playwright UI mode
npx playwright test --trace on        # Capture trace for debugging
4. Debug Failures
  • Read error output carefully
  • Use --trace on and open trace viewer: npx playwright show-trace trace.zip
  • Take screenshots on failure: await page.screenshot({ path: 'debug.png' })
  • Use page.pause() for step-by-step debugging in headed mode

Capabilities

  • Navigation: page.goto(), URL assertions, redirect verification
  • Forms: page.fill(), page.selectOption(), page.check(), multi-step wizards
  • Assertions: expect(page).toHaveURL(), expect(locator).toBeVisible(), toHaveText()
  • Screenshots: page.screenshot(), full-page, element-level
  • Visual regression: expect(page).toHaveScreenshot() with thresholds
  • Accessibility: @axe-core/playwright, ARIA role selectors, keyboard navigation
  • Network: page.route() for mocking, page.waitForResponse() for API calls

Tips

  • Use data-testid attributes for stable selectors
  • Prefer user-visible text and ARIA roles over CSS selectors
  • Use test.step() for complex multi-step flows
  • Set baseURL in playwright.config.ts
  • Use page.waitForResponse() for async navigation
  • Place test files alongside existing test patterns in the project

Comments

Markdown supported