agentleFS
ci4meci4me/CQRSTemplate/.claude/skills/playwright-automation/SKILL.md

playwright-automation

Skill0 starsChanged 6 months agoMITView on GitHub

Automate browsers, test web applications, scrape websites, and perform E2E testing using Playwright MCP. Use when working with web browsers, testing web apps, capturing screenshots, or automating web interactions.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 7 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 7

    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. Distinctive:

    Test web applications (E2E, integration tests)

    line 14
  2. Very specific:

    Prefer semantic selectors: Use button[aria-label="Submit"] over .btn-primary

    line 150
  3. Very specific:

    Avoid fragile selectors: Don't use nth-child or deep CSS paths

    line 152
  4. Distinctive:

    Only add explicit waits for unusual cases

    line 157
  5. Distinctive:

    Always verify elements exist before interaction

    line 160
  6. Distinctive:

    Use efficient JavaScript for data extraction

    line 167
  7. Distinctive:

    Use Chrome DevTools for advanced debugging while Playwright handles automation:

    line 203
  8. Distinctive:

    Verify ARIA attributes and semantic HTML:

    line 244
  9. Distinctive:

    Use this skill whenever you need to interact with web browsers programmatically!

    line 296

“Common” is measured: kept by at least 6 in 10 of the 3 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 Browser Automation Skill

This skill enables browser automation and web testing using the Playwright MCP server. It provides accessibility-based automation without requiring screenshots or visual AI models.

When to Use This Skill

Activate this skill when you need to:

  • Test web applications (E2E, integration tests)
  • Automate browser interactions and user flows
  • Scrape or extract data from websites
  • Capture screenshots of web pages or components
  • Validate web application functionality
  • Fill forms and interact with web elements
  • Execute JavaScript in browser context
  • Monitor web page behavior

Core Capabilities

1. Browser Navigation

Navigate to URLs and manage browser sessions efficiently.

// Navigate to a website
mcp__playwright__puppeteer_navigate({ url: "https://example.com" })

2. Element Interaction

Click, fill, select, and hover over web elements using CSS selectors.

// Click a button
mcp__playwright__puppeteer_click({ selector: "button#submit" })

// Fill an input field
mcp__playwright__puppeteer_fill({ selector: "input[name='email']", value: "user@example.com" })

// Select dropdown value
mcp__playwright__puppeteer_select({ selector: "select#country", value: "US" })

// Hover over element
mcp__playwright__puppeteer_hover({ selector: ".tooltip-trigger" })

3. Screenshot Capture

Take full-page or element-specific screenshots.

// Full page screenshot
mcp__playwright__puppeteer_screenshot({ name: "homepage", width: 1920, height: 1080 })

// Element screenshot
mcp__playwright__puppeteer_screenshot({
  name: "login-form",
  selector: "#login-form"
})

4. JavaScript Execution

Execute JavaScript code in the browser context.

// Extract data with JavaScript
mcp__playwright__puppeteer_evaluate({
  script: "document.querySelectorAll('.product').length"
})

Workflow Examples

Example 1: E2E Login Test

1. Navigate to login page
2. Fill username and password fields
3. Click submit button
4. Take screenshot of dashboard
5. Verify successful login

Implementation:

// Step 1: Navigate
mcp__playwright__puppeteer_navigate({ url: "https://app.example.com/login" })

// Step 2: Fill credentials
mcp__playwright__puppeteer_fill({ selector: "input#username", value: "testuser" })
mcp__playwright__puppeteer_fill({ selector: "input#password", value: "password123" })

// Step 3: Submit
mcp__playwright__puppeteer_click({ selector: "button[type='submit']" })

// Step 4: Capture evidence
mcp__playwright__puppeteer_screenshot({ name: "dashboard-logged-in" })

// Step 5: Verify
mcp__playwright__puppeteer_evaluate({
  script: "document.querySelector('.user-profile') !== null"
})

Example 2: Web Scraping

1. Navigate to target website
2. Wait for content to load (auto-handled by Playwright)
3. Execute JavaScript to extract data
4. Parse and structure the data
5. Save to file

Implementation:

// Navigate to site
mcp__playwright__puppeteer_navigate({ url: "https://example.com/products" })

// Extract product data
mcp__playwright__puppeteer_evaluate({
  script: `
    Array.from(document.querySelectorAll('.product')).map(p => ({
      name: p.querySelector('.name').textContent,
      price: p.querySelector('.price').textContent,
      image: p.querySelector('img').src
    }))
  `
})

// Then use Write tool to save the extracted data

Example 3: Form Automation

1. Navigate to form page
2. Fill all required fields
3. Upload file (if needed)
4. Submit form
5. Verify success message
6. Take screenshot for record

Best Practices

1. Selector Strategy

  • Prefer semantic selectors: Use button[aria-label="Submit"] over .btn-primary
  • Use data attributes: [data-testid="login-button"] for stable selectors
  • Avoid fragile selectors: Don't use nth-child or deep CSS paths

2. Wait for Stability

  • Playwright auto-waits for elements to be ready
  • Trust the built-in waiting mechanisms
  • Only add explicit waits for unusual cases

3. Error Handling

  • Always verify elements exist before interaction
  • Provide clear error messages with context
  • Take screenshots on failures for debugging

4. Performance Optimization

  • Reuse browser sessions when running multiple tests
  • Navigate only when necessary
  • Use efficient JavaScript for data extraction

Troubleshooting

Common Issues

Issue: Selector not found

Solution:
1. Verify the element exists on the page
2. Check if page has fully loaded
3. Try alternative selectors (id, class, aria-label)
4. Use mcp__playwright__puppeteer_evaluate to inspect DOM

Issue: Form submission fails

Solution:
1. Ensure all required fields are filled
2. Check for JavaScript validation errors
3. Verify submit button is enabled
4. Try evaluating form.submit() directly

Issue: Screenshot shows blank page

Solution:
1. Add slight delay after navigation
2. Wait for specific element to appear
3. Check if page requires JavaScript
4. Verify network connectivity

Integration with Other MCP Servers

With Chrome DevTools MCP

Use Chrome DevTools for advanced debugging while Playwright handles automation:

  • Playwright: Performs automated actions
  • Chrome DevTools: Inspects network, console, performance

With Puppeteer MCP

Both can complement each other:

  • Playwright: Modern, accessibility-focused automation
  • Puppeteer: Additional browser control capabilities

With IDE MCP

Combine with IDE diagnostics:

  • Playwright: Tests web application
  • IDE MCP: Provides code diagnostics and suggestions

Advanced Techniques

1. Multi-step Workflows

Chain multiple actions in sequence:

Navigate → Fill Form → Submit → Wait → Verify → Screenshot → Report

2. Data-Driven Testing

Loop through test data arrays:

// For each test case:
for (const testCase of testData) {
  navigate → fill(testCase) → submit → verify
}

3. Visual Regression Testing

Compare screenshots over time:

1. Take baseline screenshot
2. Make UI changes
3. Take new screenshot
4. Compare visually (manual or automated)

4. Accessibility Testing

Verify ARIA attributes and semantic HTML:

mcp__playwright__puppeteer_evaluate({
  script: `
    const issues = [];
    document.querySelectorAll('button').forEach(btn => {
      if (!btn.hasAttribute('aria-label') && !btn.textContent.trim()) {
        issues.push('Button without label: ' + btn.outerHTML);
      }
    });
    issues;
  `
})

Resources

Playwright Documentation

Testing Strategies

  • E2E Testing Best Practices
  • Page Object Model patterns
  • Test data management
  • CI/CD integration

Example Use Cases

This skill should be automatically activated when users say:

  • "Test the login flow on myapp.com"
  • "Take a screenshot of the homepage"
  • "Automate user registration process"
  • "Scrape product listings from ecommerce site"
  • "Fill out the contact form and submit"
  • "Click through the checkout process"
  • "Verify the search functionality works"
  • "Capture screenshots of all pages"

Summary

The Playwright Automation skill provides powerful browser automation capabilities through the Playwright MCP server. It excels at E2E testing, web scraping, form automation, and screenshot capture—all using accessibility-based selectors for robust, maintainable automation scripts.

Key Strengths:

  • Accessibility-first approach (no visual AI needed)
  • Auto-waiting for element stability
  • Modern, fast browser automation
  • Comprehensive interaction capabilities
  • Screenshot and visual documentation
  • JavaScript execution in browser context

Use this skill whenever you need to interact with web browsers programmatically!

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.