Playwright

Use MCP Playwright for automated browser testing and web automation.

11 stars

Best use case

Playwright is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use MCP Playwright for automated browser testing and web automation.

Teams using Playwright should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/playwright/SKILL.md --create-dirs "https://raw.githubusercontent.com/hivellm/rulebook/main/templates/skills/modules/playwright/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/playwright/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How Playwright Compares

Feature / AgentPlaywrightStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use MCP Playwright for automated browser testing and web automation.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

<!-- PLAYWRIGHT:START -->
# Playwright MCP Instructions

**CRITICAL**: Use MCP Playwright for automated browser testing and web automation.

## Core Operations

### Navigation & Screenshots
```typescript
await playwright.navigate({ url: "https://example.com" });
await playwright.takeScreenshot({ fullPage: true, filename: "page.png" });
```

### Interaction
```typescript
// Click
await playwright.click({ element: "Submit Button", ref: "button[type='submit']" });

// Type
await playwright.type({ element: "Search", ref: "#search", text: "query" });

// Fill form
await playwright.fillForm({
  fields: [
    { name: "Email", type: "textbox", ref: "#email", value: "user@example.com" },
    { name: "Password", type: "textbox", ref: "#password", value: "secret" }
  ]
});
```

### DOM & Monitoring
```typescript
// Get accessibility tree
const snapshot = await playwright.snapshot();

// Console errors
const errors = await playwright.getConsoleMessages({ onlyErrors: true });

// Network requests
const requests = await playwright.getNetworkRequests();
```

## Common Patterns

### Login Flow
```typescript
1. navigate to login page
2. fillForm with credentials
3. click submit button
4. waitFor dashboard text
5. verify success via snapshot
```

### Error Detection
```typescript
const errors = await playwright.getConsoleMessages({ onlyErrors: true });
if (errors.length > 0) {
  await playwright.takeScreenshot({ filename: "error-state.png" });
}
```

## Best Practices

✅ **DO:**
- Wait for specific conditions (not time delays)
- Use descriptive element names
- Handle dialogs (`handleDialog`)
- Check console errors after actions
- Take screenshots at critical points

❌ **DON'T:**
- Use hard-coded delays
- Use generic element selectors
- Ignore console errors
- Use relative file paths (uploads)

## Configuration

```json
{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-playwright"]
    }
  }
}
```

<!-- PLAYWRIGHT:END -->