All guides
Self-healing · 8 minutes · Intermediate

Auto-fix broken Cypress selectors with Claude

A UI refactor lands. Three Cypress selectors stop matching. Instead of two engineers chasing them down for half a day, Claude reads the live DOM via MCP and patches the failing step only.

The painful default

UI refactors are a fact of life. A button gets rewrapped, a class name changes, a data-test attribute is dropped during a redesign. Your Cypress or Playwright suite goes red overnight. Then someone has to:

  1. Open the failing test, find the broken line.
  2. Open DevTools, find the new selector.
  3. Update the test, re-run, hope nothing else regressed.
  4. Repeat for every other broken step in the suite.

For a 47-test suite with 3 broken selectors per refactor, this is 30-90 minutes of stop-the-world work.

The Claude + MCP flow

With Claude MCP test automation, the same scenario is one chat message:

The login selector broke after yesterday's UI refactor.
Fix it for me.

Claude orchestrates four MCP tool calls:

  1. list_test_runs — find the failing run, get the broken step ID.
  2. inspect_page — visit the page in a real Playwright browser, return stable selectors for the new element.
  3. replace_test_steps — patch only the broken step, leaving the other 11 untouched.
  4. run_test — re-run to confirm green.

Total time: ~30 seconds. Total cost: about $0.01 in LLM tokens.

Why this is safer than full-suite re-prompting: Claude touches only the failing step. Steps that already pass don't get rewritten — so a flaky AI rewrite can't introduce new regressions in working code.

Does this work for Cypress, or only Playwright?

The selector layer is engine-agnostic. E2Easy's MCP server returns CSS, ARIA, xpath and role-based locator candidates from the live DOM. Whether you run them through Cypress, Playwright or our own runner, the selectors slot in directly.

For Cypress migration, the typical flow is: re-record the broken Cypress test in E2Easy via Claude (one chat), then keep running it through the E2Easy runner with full CI replay support.

What about destructive edits?

replace_test_steps and delete_test are flagged as destructive in the MCP schema. Claude is required to confirm with you before calling them. You see exactly which steps are about to change and approve before anything is written.

Stop hunting selectors. Try it free.

Self-healing on broken selectors · OAuth 2.1 + PKCE · No credit card