| name | browser-testing |
| description | Drive real browsers via Chrome DevTools MCP: navigate pages, capture snapshots, run responsive checks, and collect console/perf traces. Use when the user mentions: 'validate UI change in Chrome', 'capture a screenshot', 'run responsive checks', or 'collect console logs'. Trigger terms: browser testing, DevTools, console logs, screenshot, responsive testing |
Browser Testing with Chrome DevTools MCP
For project-specific test app, selectors, suites, and breakpoint config, see testing-config.md.
Chrome MCP Tools Reference
Navigation
mcp_chrome-devtoo_navigate_page({ type: 'url', url: 'http://localhost:<port>/places' })
mcp_chrome-devtoo_navigate_page({ type: 'reload' })
Interaction
mcp_chrome-devtoo_click({ uid: 'element_uid' })
mcp_chrome-devtoo_type({ uid: 'input_uid', text: 'search query' })
mcp_chrome-devtoo_wait_for({ text: 'Expected text' })
Validation (preferred — lightweight)
mcp_chrome-devtoo_evaluate_script({
function: '() => document.querySelectorAll(".place-card").length'
})
mcp_chrome-devtoo_evaluate_script({
function: '() => window.location.href'
})
mcp_chrome-devtoo_evaluate_script({
function: '() => !!document.querySelector("[data-testid=filter-topbar]")'
})
mcp_chrome-devtoo_evaluate_script({
function: '() => document.querySelector("h1")?.textContent'
})
mcp_chrome-devtoo_evaluate_script({
function: '() => new URL(window.location.href).searchParams.toString()'
})
Screenshots (use sparingly — MAX 3 per session)
mcp_chrome-devtoo_take_screenshot({ format: 'png' })
mcp_chrome-devtoo_take_snapshot()
Performance
mcp_chrome-devtoo_performance_start_trace({ reload: true, autoStop: true })
mcp_chrome-devtoo_performance_analyze_insight({ insightSetId: 'set_id', insightName: 'LCPBreakdown' })
Testing Workflow
1. Setup
Start the dev server.
2. Initial State
mcp_chrome-devtoo_navigate_page({ type: 'url', url: 'http://localhost:<port>/places' })
mcp_chrome-devtoo_wait_for({ text: 'places' })
mcp_chrome-devtoo_evaluate_script({
function: '() => ({ url: window.location.href, title: document.title })'
})
3–4. Test Interactions & Edge Cases
mcp_chrome-devtoo_click({ uid: 'filter_uid' })
mcp_chrome-devtoo_evaluate_script({
function: '() => document.querySelectorAll(".place-card").length'
})
mcp_chrome-devtoo_navigate_page({
type: 'url', url: 'http://localhost:<port>/places?q=nonexistent-venue-xyz'
})
mcp_chrome-devtoo_evaluate_script({
function: '() => !!document.querySelector("[data-testid=empty-state]")'
})
5. Console Error Check
mcp_chrome-devtoo_list_console_messages()
6. Responsive Breakpoint Testing
Test every UI change at all responsive breakpoints — most layout bugs surface at smaller viewports. Define breakpoints in your project's testing config.
How to Resize
mcp_chrome-devtoo_resize_page({ width: 375, height: 812 })
mcp_chrome-devtoo_resize_page({ width: 768, height: 1024 })
mcp_chrome-devtoo_resize_page({ width: 1440, height: 900 })
Per-Breakpoint Verification
- Verify interactions at each size (not layout only)
- Prefer
evaluate_script() assertions over screenshots; reserve screenshots for failures
Regression Re-Test Workflow
When re-testing after a fix:
- Read previous
result.json for failing tests.
- Run build + lint to verify fix compiles.
- Start dev server.
- Re-run ALL tests from previous suite (fixes can regress other tests).
- Compare results — every test must PASS.
- Write updated
result.json.
If any test still fails: analyze, fix, repeat. Do NOT stop.
Context Management
- ONE focus area per session.
- MAX 3 screenshots — use
evaluate_script() for most checks.
- Clear browser state between unrelated test flows.