Configure Browser Automation
Configure Browser Automation
Section titled âConfigure Browser AutomationâTEA can interact with live browsers during test generation â to verify selectors, explore UIs, capture evidence, and debug failures. Two complementary tools are available:
CLI and MCP are complementary tools, not competitors. Auto mode uses each where it shines â CLI for token-efficient stateless snapshots, MCP for rich stateful automation â while giving users full control to override when they know better.
The Four Modes
Section titled âThe Four ModesâTEAâs browser automation is controlled by tea_browser_automation in _bmad/tea/config.yaml:
tea_browser_automation: 'auto' # auto | cli | mcp | none| Mode | Behavior |
|---|---|
auto | TEA picks the right tool per action â CLI for quick lookups, MCP for complex flows. Falls back gracefully if only one tool is installed. (Recommended) |
cli | CLI only. MCP ignored even if configured. |
mcp | MCP only. CLI ignored even if installed. Same as the old tea_use_mcp_enhancements: true. |
none | No browser interaction. TEA generates from docs and code analysis only. |
Prerequisites
Section titled âPrerequisitesâFor CLI (cli or auto mode)
Section titled âFor CLI (cli or auto mode)ânpm install -g @playwright/cli@latest # Install globally (Node.js 18+)playwright-cli install --skills # Register as an agent skillThe global npm install is one-time. The skills install (playwright-cli install --skills) should be run from your project root â it registers skills in your active toolâs project skills directory (for example, Claude Code uses .claude/skills/ and Codex uses .agents/skills/). Agents without skills support can still use the CLI directly via playwright-cli --help.
For MCP (mcp or auto mode)
Section titled âFor MCP (mcp or auto mode)âAdd these MCP server entries to your toolâs configuration file:
{ "mcpServers": { "playwright": { "type": "stdio", "command": "npx", "args": ["-y", "@playwright/mcp@latest"] }, "playwright-test": { "type": "stdio", "command": "npx", "args": ["playwright", "run-test-mcp-server"] }, "smartbear": { "type": "stdio", "command": "npx", "args": ["-y", "@smartbear/mcp@latest"], "env": { "PACT_BROKER_BASE_URL": "https://{tenant}.pactflow.io", "PACT_BROKER_TOKEN": "<your-api-token>" } } }}The smartbear server is optional â only needed if you use the Pact MCP integration for contract testing workflows. See the pact-mcp knowledge fragment for details.
Where to put the config
Section titled âWhere to put the configâ| Tool | Config File | Format |
|---|---|---|
| Claude Code | ~/.claude.json | JSON (mcpServers) |
| Codex | ~/.codex/config.toml | TOML ([mcp_servers]) |
| Gemini CLI | ~/.gemini/settings.json | JSON (mcpServers) |
| Cursor | ~/.cursor/mcp.json | JSON (mcpServers) |
| Windsurf | ~/.codeium/windsurf/mcp_config.json | JSON (mcpServers) |
| VS Code (Copilot) | .vscode/mcp.json | JSON (servers) |
Claude Code tip: Prefer the
claude mcp addCLI over manual JSON editing â it sets the correcttypefield and validates the config. Use-s userfor global (all projects) or omit for per-project (default).
CLI shortcuts
Section titled âCLI shortcutsâClaude Code and Codex support adding MCP servers from the command line:
# Claude Code â Playwright (use -s user for global, omit for per-project)claude mcp add -s user --transport stdio playwright -- npx -y @playwright/mcp@latestclaude mcp add -s user --transport stdio playwright-test -- npx playwright run-test-mcp-server
# Claude Code â SmartBear (Pact) â use add-json for servers with env varsclaude mcp add-json -s user smartbear \ '{"type":"stdio","command":"npx","args":["-y","@smartbear/mcp@latest"],"env":{"PACT_BROKER_BASE_URL":"https://{tenant}.pactflow.io","PACT_BROKER_TOKEN":"<your-token>"}}'
# Codex â Playwrightcodex mcp add playwright -- npx -y @playwright/mcp@latestcodex mcp add playwright-test -- npx playwright run-test-mcp-server
# Codex â SmartBear (Pact)codex mcp add smartbear -- npx -y @smartbear/mcp@latestCodex TOML format
Section titled âCodex TOML formatâCodex uses TOML instead of JSON. If editing the config file manually:
[mcp_servers.playwright]command = "npx"args = ["-y", "@playwright/mcp@latest"]
[mcp_servers.playwright-test]command = "npx"args = ["playwright", "run-test-mcp-server"]
[mcp_servers.smartbear]command = "npx"args = ["-y", "@smartbear/mcp@latest"]
[mcp_servers.smartbear.env]PACT_BROKER_BASE_URL = "https://{tenant}.pactflow.io"PACT_BROKER_TOKEN = "<your-api-token>"Note the key is mcp_servers (underscored), not mcpServers.
How Auto Mode Works
Section titled âHow Auto Mode WorksâWhen tea_browser_automation: "auto", TEA picks the right tool per action:
Priority 1: User Override
Section titled âPriority 1: User OverrideâIf you explicitly request CLI or MCP in your prompt (e.g., âuse the CLI to explore this pageâ), TEA honors that.
Priority 2: Auto Heuristic
Section titled âPriority 2: Auto HeuristicâCLI preferred for quick, stateless tasks:
- Open page, take snapshot, list elements
- One-shot data capture (selectors, labels, page structure)
- Locator verification (checking if a locator exists on a page)
- Capturing screenshots/traces for evidence
MCP preferred for stateful, multi-step flows:
- Long sequences where state must carry across many steps
- Multi-tab flows, file uploads, repeated edits
- Complex interaction patterns (drag/drop, multi-step wizards)
- Self-healing mode (analyzing failures with full DOM access)
Priority 3: Fallback
Section titled âPriority 3: Fallbackâ- If CLI returns âcommand not foundâ -> fall back to MCP
- If MCP is unavailable -> fall back to CLI
- If neither is available -> fall back to
nonemode
Which Workflows Benefit
Section titled âWhich Workflows Benefitâ| Workflow | Default Tool (auto) | Use Case |
|---|---|---|
test-design | CLI | Page discovery, snapshots â stateless |
atdd | CLI + MCP | CLI for baseline capture, MCP for complex interactions |
automate | CLI + MCP | CLI for selector verification, MCP for healing |
test-review | CLI | Traces, screenshots, network â stateless evidence |
nfr-assess | CLI | Network monitoring, timing â stateless |
Overriding Per Request
Section titled âOverriding Per RequestâEven in auto mode, you can override per-request:
"Use the CLI to snapshot the login page""Open MCP browser and walk through the checkout wizard"TEA will honor your explicit request.
Migrating from tea_use_mcp_enhancements
Section titled âMigrating from tea_use_mcp_enhancementsâThe old boolean flag tea_use_mcp_enhancements has been replaced:
| Old Setting | New Equivalent |
|---|---|
tea_use_mcp_enhancements: true | tea_browser_automation: "auto" |
tea_use_mcp_enhancements: false | tea_browser_automation: "none" |
The BMAD installer will auto-migrate existing configs.
Troubleshooting
Section titled âTroubleshootingâCLI Not Working
Section titled âCLI Not Workingâ# Verify CLI is installedplaywright-cli --version
# Install if missingnpm install -g @playwright/cli@latest
# Install skillsplaywright-cli install --skillsMCP Not Working
Section titled âMCP Not Workingâ- Check MCP servers are configured in your IDE
- Restart your IDE after configuration changes
- Verify:
npx @playwright/mcp@latest --version
Auto Mode Not Selecting Expected Tool
Section titled âAuto Mode Not Selecting Expected ToolâAuto mode logs its decisions:
- âUsing CLI for snapshot (stateless discovery)â
- âUsing MCP for multi-step recording (stateful flow)â
Check the workflow output for these messages.
Session Cleanup Issues
Section titled âSession Cleanup IssuesâIf you see orphaned browser processes:
# List active sessionsplaywright-cli list
# Close a specific sessionplaywright-cli -s=tea-explore close
# Emergency cleanup (kills ALL sessions -- use only manually)playwright-cli close-allRelated
Section titled âRelatedâGenerated with BMad Method - TEA (Test Engineering Architect)