Playwright E2E Test Generator

VerifiedSafe

Generates end-to-end tests with Playwright for web applications. Analyzes page structure and user interactions to create automated browser tests covering user flows, UI, and integration. Includes test templates, best practices for selectors and assertions, and configuration for running tests.

Sby Skills Guide Bot
TestingIntermediate
6/2/2026
Claude CodeCursorWindsurfCopilotCodex
#playwright#e2e-testing#ui-testing#test-automation

Recommended for

Automated summary

Generates end-to-end (e2e) tests using Playwright for web applications by analyzing HTML/JS structure and producing isolated, maintainable tests.

Strengths

  • Automatically analyzes HTML/JS to identify key selectors and interactions
  • Follows Playwright best practices (data-testid, roles, specific assertions)
  • Sets up test environment (playwright.config.ts) and dependencies
  • Promotes independent and reproducible tests

Limitations

  • Relies on accurate source code analysis; may miss complex dynamic elements
  • Does not generate tests for advanced async interactions (WebSockets, complex animations)
  • Requires manual verification to ensure generated tests are relevant
When to use it

Use this skill to quickly create e2e tests for existing or in-development web pages.

When not to use it

Avoid for unit tests or API tests, or when the web app uses highly dynamic frameworks without stable selectors.

Security analysis

Safe
Quality score93/100

The skill provides instructions for generating Playwright e2e tests. It contains no destructive commands, no exfiltration, no obfuscated payloads. The only shell command is 'python3 -m http.server' for a local dev server, which is a standard practice. No security risks identified.

No concerns found

How this analysis is made

Examples

Pomodoro Timer Tests
Generate Playwright e2e tests for a pomodoro timer application. The app has a start button, pause button, work/break mode toggles, and saves progress to localStorage. Create tests for starting the timer, switching modes, and verifying localStorage persistence.
Modal Interaction Tests
Generate Playwright e2e tests for a modal settings dialog. The page has a button to open a modal, inputs inside the modal, a save button, and a close button. Ensure the modal appears/disappears correctly and settings are saved.

name: qc-web description: Generate end-to-end (e2e) tests using Playwright for web applications. Use when creating automated browser tests, testing user flows, UI testing, or writing integration tests for web pages.

QC Web - Playwright E2E Test Generator

Instructions

When generating e2e tests with Playwright, follow these steps:

1. Analyze the Target

  • Read the HTML/JavaScript files to understand the page structure
  • Identify key user interactions (clicks, inputs, navigation)
  • Note important DOM selectors (IDs, classes, data-testid attributes)
  • Understand the expected behavior and state changes

2. Test Structure

Create tests in the tests/ directory with .spec.ts extension:

tests/
  example.spec.ts
  fixtures/
    test-data.json
  utils/
    helpers.ts

3. Writing Tests

Use this template for each test file:

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

test.describe('Feature Name', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto('/');
  });

  test('should describe expected behavior', async ({ page }) => {
    // Arrange - setup test data/state

    // Act - perform user actions
    await page.click('button#start');

    // Assert - verify expected outcomes
    await expect(page.locator('.result')).toBeVisible();
  });
});

4. Best Practices

Selectors (in order of preference):

  1. data-testid attributes: page.locator('[data-testid="submit-btn"]')
  2. Role-based: page.getByRole('button', { name: 'Submit' })
  3. Text content: page.getByText('Click me')
  4. CSS selectors: page.locator('.class-name')

Assertions:

  • Use expect with specific matchers
  • Wait for elements: await expect(locator).toBeVisible()
  • Check text: await expect(locator).toHaveText('expected')
  • Check attributes: await expect(locator).toHaveAttribute('disabled')

Test Independence:

  • Each test should be independent and isolated
  • Use beforeEach for common setup
  • Clean up state in afterEach if needed

5. Configuration

Create playwright.config.ts if not exists:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  testDir: './tests',
  fullyParallel: true,
  retries: process.env.CI ? 2 : 0,
  reporter: 'html',
  use: {
    baseURL: 'http://localhost:8000',
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
  },
  webServer: {
    command: 'python3 -m http.server 8000',
    url: 'http://localhost:8000',
    reuseExistingServer: !process.env.CI,
  },
});

6. Running Tests

# Install Playwright
yarn add -D @playwright/test
yarn playwright install

# Run tests
yarn playwright test

# Run with UI mode
yarn playwright test --ui

# Run specific test file
yarn playwright test tests/example.spec.ts

# Debug mode
yarn playwright test --debug

Examples

Timer Application Test

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

test.describe('Pomodoro Timer', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto('/');
  });

  test('should start timer when clicking start button', async ({ page }) => {
    await page.click('#start-btn');

    await expect(page.locator('#timer')).toBeVisible();
    await expect(page.locator('#status')).toHaveText('Running');
  });

  test('should switch between work and break modes', async ({ page }) => {
    await page.click('[data-mode="work"]');
    await expect(page.locator('.mode-indicator')).toHaveText('Work');

    await page.click('[data-mode="shortBreak"]');
    await expect(page.locator('.mode-indicator')).toHaveText('Short Break');
  });

  test('should save progress to localStorage', async ({ page }) => {
    await page.click('#start-btn');
    await page.waitForTimeout(1000);
    await page.click('#pause-btn');

    const savedData = await page.evaluate(() => {
      return localStorage.getItem('pomodoroTimeline');
    });

    expect(savedData).not.toBeNull();
  });
});

Modal/Settings Test

test.describe('Settings Modal', () => {
  test('should open and close settings modal', async ({ page }) => {
    await page.click('#settings-btn');
    await expect(page.locator('.modal')).toBeVisible();

    await page.click('.modal-close');
    await expect(page.locator('.modal')).toBeHidden();
  });

  test('should switch between tabs', async ({ page }) => {
    await page.click('#settings-btn');

    await page.click('[data-tab="sound"]');
    await expect(page.locator('.tab-content[data-tab="sound"]')).toBeVisible();

    await page.click('[data-tab="library"]');
    await expect(page.locator('.tab-content[data-tab="library"]')).toBeVisible();
  });
});

Form Interaction Test

test('should handle form submission', async ({ page }) => {
  await page.fill('input[name="duration"]', '30');
  await page.selectOption('select#mode', 'work');
  await page.check('input#notifications');

  await page.click('button[type="submit"]');

  await expect(page.locator('.success-message')).toBeVisible();
});

Version History

  • v1.0.0 (2025-12-03): Initial release

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/playwright-e2e-test-generator-mma3js19/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/playwright-e2e-test-generator-mma3js19' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/playwright-e2e-test-generator-mma3js19/download' --output '.skill-downloads/playwright-e2e-test-generator-mma3js19/SKILL.md.part' && mv '.skill-downloads/playwright-e2e-test-generator-mma3js19/SKILL.md.part' '.skill-downloads/playwright-e2e-test-generator-mma3js19/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/playwright-e2e-test-generator-mma3js19/SKILL.md' && test -s '.skill-downloads/playwright-e2e-test-generator-mma3js19/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/qc-web' && cp -R '.skill-downloads/playwright-e2e-test-generator-mma3js19' '.claude/skills/qc-web'

Cursor
test -f '.skill-downloads/playwright-e2e-test-generator-mma3js19/SKILL.md' && test -s '.skill-downloads/playwright-e2e-test-generator-mma3js19/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/qc-web' && cp -R '.skill-downloads/playwright-e2e-test-generator-mma3js19' '.cursor/skills/qc-web'

Codex
test -f '.skill-downloads/playwright-e2e-test-generator-mma3js19/SKILL.md' && test -s '.skill-downloads/playwright-e2e-test-generator-mma3js19/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/qc-web' && cp -R '.skill-downloads/playwright-e2e-test-generator-mma3js19' '.agents/skills/qc-web'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/playwright-e2e-test-generator-mma3js19'

openskills read 'playwright-e2e-test-generator-mma3js19'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/playwright-e2e-test-generator-mma3js19/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills