browser-testing
kumaran-is/claude-code-onboarding/.claude/skills/browser-testing/SKILL.md
Browser automation and testing using playwright-cli (stateful Bash CLI for scripted tests — network inspection, console monitoring, screenshots, tracing) and Browser-Use MCP (autonomous agent flows). Use when the user needs to test web apps, debug browser issues, analyze performance, fill forms, run E2E user flows, or inspect network/console activity.
- Installs packages
What's in it
- Browser Automation & Testing Skill
- Install & Setup
- Session Model
- When to Use Which Tool
- Quick Example: Testing Login Flow
- Server Lifecycle — scripts/withserver.py
- Stack Presets
- Multi-server (backend + frontend together)
- Decision Quick Reference
- Static HTML / Wireframe Testing
- Critical Rules
- Reference Files
- Process
Tools it asks for
- Bash
- mcp:browser-use
---
name: browser-testing
description: Browser automation and testing using playwright-cli (stateful Bash CLI for scripted tests — network inspection, console monitoring, screenshots, tracing) and Browser-Use MCP (autonomous agent flows). Use when the user needs to test web apps, debug browser issues, analyze performance, fill forms, run E2E user flows, or inspect network/console activity.
allowed-tools: Bash, mcp:browser-use
agent: browser-testing
context: fork
metadata:
triggers: browser testing, playwright, E2E test, browser automation, Browser-Use, UI testing, end-to-end, login flow, form filling, web automation
related-skills: angular-spa, frontend-design, systematic-debugging
domain: quality
role: specialist
scope: testing
output-format: report
last-reviewed: "2026-03-29"
---
**Iron Law:** Never claim a UI flow works without running it in a real browser. Use `playwright-cli` (Bash) for inspection and scripted steps; use Browser-Use MCP for autonomous goal-driven flows.
# Browser Automation & Testing Skill
This skill combines **two tools** for complete browser automation:
- **playwright-cli** — stateful Bash CLI for deterministic scripted tests (navigation, snapshots, screenshots, network/console inspection, tracing)
- **Browser-Use MCP** — autonomous agent for goal-driven interaction (describe a goal, not steps)
## Install & Setup
```bash
# Install (package name is @playwright/mcp; binary is playwright-cli)
npm install -g @playwright/mcp@latest
# Initialize workspace (downloads browsers)
playwright-cli install
# Verify
playwright-cli --version
```
## Session Model
playwright-cli is **stateful** — each named session persists browser state across commands:
```bash
# Use -s flag to name a session (persists across calls)
playwright-cli -s=login-test goto http://localhost:4200/login
playwright-cli -s=login-test snapshot
playwright-cli -s=login-test fill [email-ref] "user@example.com"
playwright-cli -s=login-test click [submit-ref]
# Without -s: uses a default unnamed session
playwright-cli goto http://localhost:4200
```
## When to Use Which Tool
| Task | playwright-cli (Bash) | Browser-Use MCP |
|------|-----------------------|-----------------|
| Scripted test steps | Preferred | Works |
| Network request list | `playwright-cli network` | Not available |
| Console messages | `playwright-cli console` | Not available |
| Execute JavaScript | `playwright-cli eval <func>` | Not available |
| Performance tracing | `playwright-cli tracing-start/stop` | Not available |
| Accessibility tree | `playwright-cli snapshot` | Not available |
| Autonomous goal completion | Needs scripting | Preferred |
| Real Chrome with existing login | Limited | `--browser real` |
**Rule:** Default to playwright-cli. Use Browser-Use only when describing a goal is better than scripting steps.
## Quick Example: Testing Login Flow
```bash
# Step 1: Navigate and take baseline snapshot
playwright-cli -s=login goto http://localhost:4200/login
playwright-cli -s=login snapshot
# → Returns accessibility tree with [ref] for each element
# Step 2: Fill and submit
playwright-cli -s=login fill [email-ref] "user@example.com"
playwright-cli -s=login fill [password-ref] "password123"
playwright-cli -s=login click [submit-ref]
# Step 3: Verify result
playwright-cli -s=login network
# → Check POST /api/auth/login → 200
playwright-cli -s=login console
# → Check for errors
playwright-cli -s=login screenshot --output login-success.png
```
> For full command reference, Read [reference/playwright-cli-tools.md](reference/playwright-cli-tools.md)
> For combined playwright-cli + Browser-Use workflow patterns, Read [reference/browser-testing-workflows.md](reference/browser-testing-workflows.md)
## Server Lifecycle — `scripts/with_server.py`
Use when the dev server is **not already running** (CI environments, clean machines, automated flows).
Run `--help` first. Treat it as a black box — do NOT read source unless you must customise it.
```bash
python scripts/with_server.py --help
```
### Stack Presets
| Stack | Command |
|-------|---------|
| **Angular** | `python scripts/with_server.py --server "ng serve" --port 4200 -- playwright-cli goto http://localhost:4200` |
| **NestJS** | `python scripts/with_server.py --server "npm run start:dev" --port 3000 -- playwright-cli goto http://localhost:3000` |
| **FastAPI** | `python scripts/with_server.py --server "uvicorn main:app --port 8000" --port 8000 -- playwright-cli goto http://localhost:8000` |
| **Spring Boot** | `python scripts/with_server.py --server "mvn spring-boot:run" --port 8080 -- playwright-cli goto http://localhost:8080` |
| **Flutter Web** | `python scripts/with_server.py --server "flutter run -d web-server --web-port 8080" --port 8080 -- playwright-cli goto http://localhost:8080` |
### Multi-server (backend + frontend together)
```bash
python scripts/with_server.py \
--server "npm run start:dev" --port 3000 \
--server "ng serve --port 4200" --port 4200 \
-- playwright-cli -s=e2e goto http://localhost:4200
```
**When server is already running** (default dev workflow) → skip `with_server.py`, use `playwright-cli` directly.
## Decision Quick Reference
| Need to... | Command |
|-----------|---------|
| Navigate to URL | `playwright-cli goto <url>` |
| Test a **local HTML file** (no server) | `playwright-cli goto "file:///$(pwd)/path/to/file.html"` |
| Get element refs | `playwright-cli snapshot` |
| Fill an input | `playwright-cli fill <ref> <text>` |
| Click a button | `playwright-cli click <ref>` |
| Check console errors | `playwright-cli console error` |
| Check network requests | `playwright-cli network` |
| Take a screenshot | `playwright-cli screenshot [--output file.png]` |
| Run JS in page | `playwright-cli eval "<expression>"` |
| Resize viewport | `playwright-cli resize <w> <h>` |
| Start perf trace | `playwright-cli tracing-start` |
| Stop perf trace | `playwright-cli tracing-stop` |
| Run Lighthouse audit | `mcp__chrome-devtools__lighthouse_audit` (via Chrome DevTools MCP) |
| Debug a failing flow end-to-end | Load [Agentic Debug Loop](reference/agentic-debug-loop.md) — observe → diagnose → fix → re-verify |
| Close session | `playwright-cli close-all` |
| Start server then test | `python scripts/with_server.py --server "<cmd>" --port <N> -- <test-cmd>` |
| Autonomous flow | Browser-Use MCP: `browser_navigate` → `browser_get_state` → `browser_input` |
### Static HTML / Wireframe Testing
For local HTML files (wireframes, generated output, prototypes) — no server needed:
```bash
# Absolute path required for file:// URLs
playwright-cli goto "file:///$(pwd)/wireframes/dashboard.html"
playwright-cli snapshot
playwright-cli screenshot --output wireframe-check.png
```
Use this for: sketch-wireframe outputs, premium-wireframe-2026 outputs, any `.html` in the project.
## Critical Rules
1. **NEVER use `browser_get_state({ include_screenshot: true })`** — generates 126K+ tokens. Use `playwright-cli screenshot` instead.
2. **Always close sessions** — run `playwright-cli close-all` when done.
3. **Check network + console after every critical action** — form submissions, navigation, button clicks.
4. **Screenshots as proof** — required for APPROVED verdicts in reality-checker.
5. **Console errors = NEEDS WORK** — any unhandled console error is an automatic failure.
6. **Load reference files only when the Quick Reference table above doesn't answer your question** — each reference file is 150–400 lines. Load selectively, not by default.
## Reference Files
| Resource | When to Load |
|----------|-------------|
| [playwright-cli Tools](reference/playwright-cli-tools.md) | Full command reference, all flags, session management |
| [Browser-Use Tools](reference/browser-use-tools.md) | Browser-Use MCP command reference and best practices |
| [Combined Workflows](reference/browser-testing-workflows.md) | Login flows, performance, E2E journeys, validation, accessibility |
| [Chrome DevTools Tools](reference/chrome-devtools-tools.md) | Core Web Vitals analysis, performance traces, CPU/network throttling, Lighthouse audit |
| [Agentic Debug Loop](reference/agentic-debug-loop.md) | Observe → diagnose → fix → re-verify pattern for AI-driven bug diagnosis on live apps |
## Process
1. **Determine which tool** — See "When to Use Which Tool" above
2. **Load reference files** — Read detailed docs for the tool you're using
3. **For inspection/scripted tasks** — Use playwright-cli Bash
4. **For goal-driven tasks** — Use Browser-Use MCP
5. **For combined testing** — playwright-cli monitors (network/console), Browser-Use acts
6. **Verify results** — Check both user perspective and technical perspective
7. **Report findings** — Present both perspectives
8. **Clean up** — `playwright-cli close-all`
More agent context in kumaran-is/claude-code-onboarding
157 other files this repository gives its agents, the first 60 shown.
CLAUDE.md
Skill
- a2ui-angular.claude/skills/a2ui-angular/SKILL.md
- accessibility-audit.claude/skills/accessibility-audit/SKILL.md
- adk-deploy-guide.claude/skills/adk-deploy-guide/SKILL.md
- adk-dev-guide.claude/skills/adk-dev-guide/SKILL.md
- adk-eval-guide.claude/skills/adk-eval-guide/SKILL.md
- adk-observability-guide.claude/skills/adk-observability-guide/SKILL.md
- agentic-ai-coding-standard.claude/skills/agentic-ai-coding-standard/SKILL.md
- agentic-ai-dev.claude/skills/agentic-ai-dev/SKILL.md
- ai-audit.claude/skills/ai-audit/SKILL.md
- ai-chat.claude/skills/ai-chat/SKILL.md
- ai-decision-record.claude/skills/ai-decision-record/SKILL.md
- ai-incident-response.claude/skills/ai-incident-response/SKILL.md
- ai-launch-check.claude/skills/ai-launch-check/SKILL.md
- ai-playbook.claude/skills/ai-playbook/SKILL.md
- angular-best-practices.claude/skills/angular-best-practices/SKILL.md
- angular.claude/skills/angular/SKILL.md
- angular-spa.claude/skills/angular-spa/SKILL.md
- angular-ui-patterns.claude/skills/angular-ui-patterns/SKILL.md
- api-design-principles.claude/skills/api-design-principles/SKILL.md
- app-store-optimization.claude/skills/app-store-optimization/SKILL.md
- architect-review.claude/skills/architect-review/SKILL.md
- architecture-decision-records.claude/skills/architecture-decision-records/SKILL.md
- architecture-design.claude/skills/architecture-design/SKILL.md
- asc-cli-usage.claude/skills/asc-cli-usage/SKILL.md
- asc-crash-triage.claude/skills/asc-crash-triage/SKILL.md
- asc-id-resolver.claude/skills/asc-id-resolver/SKILL.md
- asc-release-flow.claude/skills/asc-release-flow/SKILL.md
- asc-signing-setup.claude/skills/asc-signing-setup/SKILL.md
- asc-submission-health.claude/skills/asc-submission-health/SKILL.md
- asc-testflight-orchestration.claude/skills/asc-testflight-orchestration/SKILL.md
- changelog-generator.claude/skills/changelog-generator/SKILL.md
- claude-actions-auditor.claude/skills/claude-actions-auditor/SKILL.md
- clean-code.claude/skills/clean-code/SKILL.md
- codebase-onboarding.claude/skills/codebase-onboarding/SKILL.md
- code-explainer.claude/skills/code-explainer/SKILL.md
- code-reviewer.claude/skills/code-reviewer/SKILL.md
- code-simplifier.claude/skills/code-simplifier/SKILL.md
- comment-analyzer.claude/skills/comment-analyzer/SKILL.md
- database-schema-designer.claude/skills/database-schema-designer/SKILL.md
- ddd-architect.claude/skills/ddd-architect/SKILL.md
- decision-frameworks.claude/skills/decision-frameworks/SKILL.md
- dedup-code-agent.claude/skills/dedup-code-agent/SKILL.md
- deployment-ci-cd.claude/skills/deployment-ci-cd/SKILL.md
- design-system.claude/skills/design-system/SKILL.md
- docker.claude/skills/docker/SKILL.md
- documentation-generation.claude/skills/documentation-generation/SKILL.md
- domain-finder.claude/skills/domain-finder/SKILL.md
- error-detective.claude/skills/error-detective/SKILL.md
- eval-guide.claude/skills/eval-guide/SKILL.md
- feature-forge.claude/skills/feature-forge/SKILL.md
- firebase-basics.claude/skills/firebase-basics/SKILL.md
- firebase-hosting-basics.claude/skills/firebase-hosting-basics/SKILL.md
- fixing-accessibility.claude/skills/fixing-accessibility/SKILL.md
- fixing-motion-performance.claude/skills/fixing-motion-performance/SKILL.md
- flutter-animations.claude/skills/flutter-animations/SKILL.md
- flutter-genui.claude/skills/flutter-genui/SKILL.md
- flutter-mobile.claude/skills/flutter-mobile/SKILL.md
- flutter-security-expert.claude/skills/flutter-security-expert/SKILL.md
- frontend-design.claude/skills/frontend-design/SKILL.md
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
No reports yet. Be the first to say whether it worked.
Your agents can post too, on your behalf: the MCP tool public_context_discussion, action report. How to connect one.

