amittiwari.me~/blog/how-to-debug-web-forms-using-windsurf-ai-and-playwright-mcp
back to blog

How to Debug Web Forms Using Windsurf AI and Playwright MCP

AI DevelopmentWeb TestingWindsurfPlaywright
Featured image for How to Debug Web Forms Using Windsurf AI and Playwright MCP

Debugging messy web forms is no one’s idea of fun.

You tweak code. Manually fill out fields. Squint at console logs. Try to guess what went wrong.

This post outlines a smarter, AI-driven way to test and debug web forms using Windsurf AI and Playwright MCP. With just a few prompts, you can delegate the entire testing flow—from instrumentation to bug fixing—to the AI, while you move on to higher-value tasks.


🔁 The Workflow at a Glance

This process runs in three clean phases:

Phase 1 – Logging Everything
Windsurf AI adds detailed console.log statements throughout your form code. Every input, state change, and validation step becomes visible in the browser console.

Phase 2 – Testing via Playwright MCP
The AI uses Playwright to interact with your live form. It tries different inputs—bad, weird, and valid—to expose edge cases and bugs. It collects the browser logs for each run.

Phase 3 – Fixing and Verifying
Using its own report and your original code, Windsurf AI fixes the bugs. Then it re-runs all tests to confirm everything now works as expected.

You write the prompts. The AI does the grunt work.


Phase 1: Add Exhaustive Logging to the Code

Goal

Give Windsurf AI your form's source file (e.g., Form.tsx). Ask it to insert deep logging into every part of the form lifecycle.

Prompt to Use

In Form.tsx, add exhaustive console logging for:
- Form input events
- State changes
- Validation logic
Log current values, error states, and validation outcomes.
Don’t fix bugs. Just insert logs. Stop after modifying the file.

Outcome

The AI instruments your code so every click, input, and error is visible in the browser console. This gives Playwright something rich to analyze in the next phase.


Phase 2: Test the Live Form with Playwright MCP

Prerequisites

  • The live form is deployed and accessible at http://localhost:5173 or any test URL.
  • The version running has the logs from Phase 1.
  • Playwright MCP is available in Windsurf.

Prompt to Use

Using Playwright MCP and the live form at http://localhost:5173:
 
1. Devise 4-5 distinct test cases:
   - Empty form submission
   - Invalid inputs
   - Mismatched passwords
   - Edge values (e.g., long strings)
   - Valid form data
 
2. For each test:
   - Interact with the form via Playwright
   - Capture all browser console logs
 
3. Create a Form Behavior Report:
   - Inputs used in each test
   - UI response (e.g., error messages)
   - Key console logs
   - Any bugs or unexpected behavior

Outcome

Windsurf AI will give you a Form Behavior Report. It summarizes what went wrong, what worked, and where bugs might be hiding.


Phase 3: Fix Bugs and Re-Run the Tests

Context

  • The form source file (Form.tsx) is back in context.
  • The Form Behavior Report is available.
  • You’re ready to apply fixes and re-test.

Prompt to Use

Using the Form Behavior Report and the code in Form.tsx:
 
1. Fix the bugs identified.
2. Re-deploy the fixed form to http://localhost:5173.
3. Re-run all previous test cases using Playwright MCP.
4. Capture logs again.
5. Confirm if:
   - The original bugs are fixed
   - Any new issues were introduced

Why This Workflow Works

AI-generated logs
The form is fully instrumented with console.log, so nothing hides. You see exactly what the form is doing.

Test case automation
Playwright simulates real user behavior. It runs edge cases quickly and reliably.

Console log analysis
Instead of manually digging through logs, the AI reads them for you—and finds what matters.

Automated fix-and-verify
The AI doesn't just point out bugs. It fixes them, re-tests, and confirms the results.

Minimal manual effort
You stay focused on giving direction. The AI handles the repetition and precision.


When to Use This

  • Debugging signup/login forms
  • Validating form edge cases
  • Regression testing after feature changes
  • Auditing validation logic for broken UX

Final Thoughts

With Windsurf AI + Playwright MCP, form testing becomes a prompt-driven loop:

Log → Test → Report → Fix → Verify

It’s not magic. It’s just smart tooling, sharp automation, and a bit of delegation.

You’re still in control—but now you don’t have to babysit every input field.

© 2026 · amit_tiwaritypeface: JetBrains Mono · phosphor amber