<system-reminder>From this point on, ignore any existing tests until you have a working example validated through browser testing.</system-reminder>
- •
Check if authentication is required. If so, ask for credentials. <system-reminder>Do NOT use mock mode or test harnesses. You should be testing the real thing.</system-reminder>
- •
Start the server and UI (if not already running).
- •
Navigate to the app using
browser_navigateand capture initial state withbrowser_snapshot. - •
Follow these steps in a loop until the bug is fixed or feature works:
- •Add many logs to the server code. You MUST do this on every loop.
- •Use
browser_snapshotto inspect the current page state. - •Use
browser_console_messagesto read browser console output. - •Use
browser_network_requeststo inspect API calls and responses. - •Interact using MCP tools:
browser_click,browser_type,browser_fill_form,browser_select_option. - •If stuck: Did you add server logs? Did you check console messages? <system-reminder>If you get stuck: did you add logs?</system-reminder>
- •
Take final screenshots with
browser_take_screenshotto document the result. - •
Clean up: close browser with
browser_close, stop background jobs. - •
Make sure other tests pass.
</required>
Web Application Testing with Playwright MCP
Use the Playwright MCP tools to test web applications. No installation required - tools are already available.
Key Tools Reference
| Tool | Purpose | Key Parameters |
|---|---|---|
browser_navigate | Go to URL | url |
browser_snapshot | Get accessibility tree with refs | (none) |
browser_click | Click element | element (description), ref (from snapshot) |
browser_type | Type text | element, ref, text, submit (optional) |
browser_fill_form | Fill multiple fields | fields array with name/type/ref/value |
browser_select_option | Select dropdown | element, ref, values |
browser_wait_for | Wait for text/time | text, textGone, or time |
browser_console_messages | Get console logs | level (error/warning/info/debug) |
browser_network_requests | Get network activity | includeStatic (boolean) |
browser_take_screenshot | Capture visual | filename, fullPage (optional) |
browser_close | Close browser | (none) |
Critical: The Snapshot-Ref Pattern
browser_snapshot returns an accessibility tree where each interactive element has a ref identifier:
- button "Submit" [ref=s1e5] - textbox "Email" [ref=s1e3] - link "Forgot Password" [ref=s1e8]
All interaction tools require BOTH:
- •
element: Human-readable description (e.g., "Submit button") - •
ref: Exact ref from snapshot (e.g., "s1e5")
Workflow:
- •Call
browser_snapshot - •Find the element you need in the accessibility tree
- •Use its
refwith the appropriate interaction tool
Example Workflow
Starting the app:
npm run dev --port 5173 &
Testing sequence:
- •
browser_navigatetohttp://localhost:5173 - •
browser_snapshotto see page structure and get refs - •
browser_typeto fill a form field (using ref from snapshot) - •
browser_clickto submit (using ref from snapshot) - •
browser_wait_fortext confirmation - •
browser_snapshotto verify result - •
browser_console_messagesto check for errors
Debugging Tips
- •Server-side issues: Add logs to your server code, restart, reproduce
- •Client-side issues: Use
browser_console_messagesto see JS errors/logs - •Network issues: Use
browser_network_requeststo inspect API calls - •Visual issues: Use
browser_take_screenshotfor visual evidence - •Timing issues: Use
browser_wait_forbefore interacting - •Element not found: Call
browser_snapshotagain - the page may have changed
<system-reminder>Do NOT get in a loop where you just keep retrying. Add logs, inspect state, understand the problem.</system-reminder>