agentleFS
kumaran-iskumaran-is/claude-code-onboarding/.claude/skills/browser-testing/SKILL.md

browser-testing

Skill36 starsChanged 6 months agoMITView on GitHub

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

8 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

5 rules. 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 8 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

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

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

    Iron Law: Never claim a UI flow works without running it in a real browser.

    line 17
  2. Distinctive:

    Rule: Default to playwright-cli.

    line 67
  3. Very specific:

    Use when the dev server is not already running (CI environments, clean machines, automated flows).

    line 96
  4. Very specific:

    Run --help first. Treat it as a black box — do NOT read source unless you must customise it.

    line 97
  5. Very specific:

    Use this for: sketch-wireframe outputs, premium-wireframe-2026 outputs, any .html in the project.

    line 157

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

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

# 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:

# 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

Taskplaywright-cli (Bash)Browser-Use MCP
Scripted test stepsPreferredWorks
Network request listplaywright-cli networkNot available
Console messagesplaywright-cli consoleNot available
Execute JavaScriptplaywright-cli eval <func>Not available
Performance tracingplaywright-cli tracing-start/stopNot available
Accessibility treeplaywright-cli snapshotNot available
Autonomous goal completionNeeds scriptingPreferred
Real Chrome with existing loginLimited--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

# 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

For combined playwright-cli + Browser-Use workflow patterns, Read 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.

python scripts/with_server.py --help

Stack Presets

StackCommand
Angularpython scripts/with_server.py --server "ng serve" --port 4200 -- playwright-cli goto http://localhost:4200
NestJSpython scripts/with_server.py --server "npm run start:dev" --port 3000 -- playwright-cli goto http://localhost:3000
FastAPIpython scripts/with_server.py --server "uvicorn main:app --port 8000" --port 8000 -- playwright-cli goto http://localhost:8000
Spring Bootpython scripts/with_server.py --server "mvn spring-boot:run" --port 8080 -- playwright-cli goto http://localhost:8080
Flutter Webpython 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)

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 URLplaywright-cli goto <url>
Test a local HTML file (no server)playwright-cli goto "file:///$(pwd)/path/to/file.html"
Get element refsplaywright-cli snapshot
Fill an inputplaywright-cli fill <ref> <text>
Click a buttonplaywright-cli click <ref>
Check console errorsplaywright-cli console error
Check network requestsplaywright-cli network
Take a screenshotplaywright-cli screenshot [--output file.png]
Run JS in pageplaywright-cli eval "<expression>"
Resize viewportplaywright-cli resize <w> <h>
Start perf traceplaywright-cli tracing-start
Stop perf traceplaywright-cli tracing-stop
Run Lighthouse auditmcp__chrome-devtools__lighthouse_audit (via Chrome DevTools MCP)
Debug a failing flow end-to-endLoad Agentic Debug Loop — observe → diagnose → fix → re-verify
Close sessionplaywright-cli close-all
Start server then testpython scripts/with_server.py --server "<cmd>" --port <N> -- <test-cmd>
Autonomous flowBrowser-Use MCP: browser_navigate → browser_get_state → browser_input

Static HTML / Wireframe Testing

For local HTML files (wireframes, generated output, prototypes) — no server needed:

# 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

ResourceWhen to Load
playwright-cli ToolsFull command reference, all flags, session management
Browser-Use ToolsBrowser-Use MCP command reference and best practices
Combined WorkflowsLogin flows, performance, E2E journeys, validation, accessibility
Chrome DevTools ToolsCore Web Vitals analysis, performance traces, CPU/network throttling, Lighthouse audit
Agentic Debug LoopObserve → 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

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.