agentleFS
kazemcodeskazemcodes/skill-tree/skills/playwright-testing/SKILL.md

playwright-testing

Skill1 starsChanged 5 months agoMITView on GitHub

Test web applications using Playwright — automate browser testing, verify UI functionality, capture screenshots for debugging

  • Installs packages

18 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use security.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • 0xSeroSkill

    security

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 17 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use data-testid attributes for reliable selectors

    line 96
  2. Distinctive:

    Avoid XPath — use Playwright's built-in locators

    line 97
  3. Very specific:

    Use page.waitForLoadState() after navigation

    line 98

“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Playwright Testing

Automate browser-based testing for web applications.

When to Use

  • Testing frontend functionality in real browser
  • Verifying UI interactions (clicks, forms, navigation)
  • Debugging visual issues
  • Capturing screenshots for documentation
  • Cross-browser compatibility testing

Setup

# Install Playwright
npm init playwright@latest

# Or add to existing project
npm install -D @playwright/test

Writing Tests

Basic Test

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

test('homepage loads correctly', async ({ page }) => {
  await page.goto('http://localhost:3000');
  await expect(page).toHaveTitle(/My App/);
  await expect(page.locator('h1')).toContainText('Welcome');
});

Form Interaction

test('login form submits', async ({ page }) => {
  await page.goto('/login');
  await page.fill('#email', 'user@example.com');
  await page.fill('#password', 'password123');
  await page.click('button[type="submit"]');
  await expect(page).toHaveURL('/dashboard');
});

Screenshot

test('capture screenshot', async ({ page }) => {
  await page.goto('http://localhost:3000');
  await page.screenshot({ path: 'screenshot.png', fullPage: true });
});

API Mocking

test('handles API error', async ({ page }) => {
  await page.route('**/api/data', route => {
    route.fulfill({ status: 500, body: 'Server Error' });
  });
  await page.goto('/');
  await expect(page.locator('.error')).toBeVisible();
});

Running Tests

# Run all tests
npx playwright test

# Run specific file
npx playwright test tests/login.spec.ts

# Run in headed mode (see browser)
npx playwright test --headed

# Run with UI mode
npx playwright test --ui

# Generate report
npx playwright show-report

Best Practices

  • Use data-testid attributes for reliable selectors
  • Avoid XPath — use Playwright's built-in locators
  • Use page.waitForLoadState() after navigation
  • Mock API calls in unit tests, hit real APIs in E2E
  • Take screenshots on failure for debugging
// Good: resilient selector
page.getByRole('button', { name: 'Submit' })

// Bad: fragile selector
page.locator('.css-x7y3k > div:nth-child(3) > button')

Debugging

// Pause for inspection
await page.pause();

// Debug with console logs
page.on('console', msg => console.log(msg.text()));

// Trace for post-mortem analysis
npx playwright test --trace on
npx playwright show-trace trace.zip

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.