Browser control
Part of agentic work is giving Claude a browser: to run UI tests, automate web flows, verify a deploy, or handle one-off tasks that don’t have an API.
There are two distinct approaches, with different strengths. Most projects end up using both.
Playwright: scripted, headless, deterministic
Playwright is Microsoft’s browser-automation library. It drives Chromium, Firefox, and WebKit via a clean API (Node, Python, Java, .NET). Headless by default, with a headed mode you can watch.
Ways Claude works with Playwright:
- Writing tests: Claude reads your app, generates test scenarios, writes Playwright tests, runs them, iterates on failures.
- CI / regression: deterministic scripts run on every commit, catch UI regressions before they ship.
- Headless automation: scrape a page, fill a form, log in and take a screenshot; one-off or scheduled.
- Playwright MCP server: Claude can call Playwright as tool calls rather than writing and running scripts, useful for interactive work.
Best when:
- You want reproducible, testable behavior
- You’re in CI or a headless environment
- The target site is stable enough to write tests against
- You want an artifact you can commit and rerun forever
Claude-in-Chrome: real browser, live session
The Claude Chrome extension gives Claude your actual Chrome browser: your cookies, your logins, your extensions, your tabs. Claude sees what you see and clicks what you’d click. Technically it’s an MCP server exposed by the extension.
The tool surface includes navigate, computer, read_page, form_input, javascript_tool, read_console_messages, gif_creator, and related primitives.
Ways Claude-in-Chrome is useful:
- Exploratory QA: “Go to the site, try this flow, tell me what you find.”
- Authenticated tasks: anything that needs a logged-in session: admin consoles, dashboards, cloud providers without good API coverage.
- Demos and screencasts: record a GIF of a flow for docs, issues, or marketing.
- One-off automations: “Pull the latest invoices from this vendor site.”
- Sites hostile to headless scrapers: operate them the way a human would.
Best when:
- The task needs your logged-in browser state
- You’re exploring a new flow rather than testing a known one
- Determinism matters less than coverage
- You want Claude to use the browser the way you would
Which to reach for
- Persistent testable behavior → Playwright
- Exploratory, interactive, or authenticated tasks → Claude-in-Chrome
- Recurring headless automation → Playwright
- One-off research, support, or admin tasks → Claude-in-Chrome
What this chapter will cover
- The two approaches in depth, with a worked example of each
- Setting up Playwright in a project (and the Playwright MCP server for interactive use)
- Installing Claude-in-Chrome and walking through the tool surface
- Pairing the two: use Claude-in-Chrome to explore a flow, then codify it as a Playwright test
- Gotchas: flakiness, auth, state leakage, when to let Claude drive vs. when to script
Resources to weave in
- Playwright: official docs
- Playwright MCP server: microsoft/playwright-mcp
- Anthropic: Claude in Chrome documentation
- A worked comparison on the same task: Playwright test vs. Claude-in-Chrome session