Skip to Content
ReferenceCommon PatternsBrowser & Test Automation

Browser Automation & Test Automation

Four approaches for automating browser operations and testing with Claude Code.


Which One Should You Start With?

Your SituationRecommendation
Want to try / Non-engineerClaude in Chrome or Cowork
Claude Code set upPlaywright MCP
Need regular testingPlaywright Test Agents

Option 1: Claude in Chrome

Chrome extension. Claude assists while seeing your screen. Install and go — no setup needed.

  • Review test procedures together visually
  • Ask “Is this page displaying correctly?”
  • Accessible for non-engineers

Option 2: Cowork

Visit claude.ai/cowork  for screen sharing with Claude. No installation needed.

  • Give instructions like “click here on this screen”
  • Show your workflow: “I do this every time. Can it be automated?”

Option 3: Playwright MCP

Claude Code directly controls the browser. Best for automating repetitive tests.

Setup

Add to .mcp.json:

{ "mcpServers": { "playwright": { "command": "npx", "args": ["-y", "@playwright/mcp"] } } }

Works immediately if Node.js is installed.

Usage

"Open this URL, log in, and screenshot the order list" "Fill this form with 10 test entries" "Navigate product → cart → checkout, screenshot each step"

Playwright CLI (Token-Efficient)

@playwright/cli uses shell commands instead of MCP. ~4x more token-efficient (114k → 27k tokens/task).

npm install -g @playwright/cli

Option 4: Playwright Test Agents

Microsoft’s AI test agents covering the full cycle: planning → code generation → healing.

AgentRoleWhat It Does
PlannerTest PlanningExplores the app, generates test plan
GeneratorCode GenerationCreates Playwright tests from the plan
HealerTest HealingRuns tests → auto-fixes failures → re-runs

Setup

npx playwright init-agents

Always review auto-generated test plans and test code to ensure they match your intended test scenarios before running them.


Before/After

ManualPlaywright + Claude Code
Test planningWrite by handPlanner Agent auto-generates
Test codeWrite by handGenerator Agent auto-generates
Browser opsManualAutomated
ScreenshotsManualAuto-captured per step
Test failuresManual fixHealer Agent auto-repairs
ReportsManual”Summarize results” → auto-generated

References

Last updated on