Self-healing tests

How BugBrain self-healing tests survive UI changes — steps stored as semantic intent, a four-tier fallback from cached fingerprints to semantic locators, automatic healing recorded to a corpus, and deterministic export to Playwright TypeScript.

The single biggest cost of traditional UI test automation is maintenance: a developer renames a CSS class, moves a button, or restructures a form, and dozens of tests turn red overnight even though the app still works. BugBrain is built to make that pain go away. Tests describe what should happen, not the exact technical handle to grab — and when the page shifts underneath them, the agent repairs them instead of breaking.

Steps are intent, not selectors#

A BugBrain test step is stored as semantic intent — an instruction like "click the primary checkout button" or "enter the email into the sign-up form" — rather than a brittle selector like a long CSS path or XPath. These are called IR steps (an intermediate representation of the step's meaning).

This is the foundation of self-healing. A selector breaks the instant the underlying markup changes; intent doesn't. "Click the checkout button" stays true whether the button's class is renamed, its position moves, or its styling changes. The test knows what it's trying to accomplish, so it can adapt to how the page chooses to render that today.

The four-tier fallback#

At execution time, each step is resolved into a concrete element on the page through a layered fallback. BugBrain tries the most reliable, lowest-risk option first and falls back gracefully:

  1. Cached element fingerprint

    First it tries a saved fingerprint of the element from a previous run — the fastest and most precise match when the element hasn't meaningfully changed.
  2. Semantic locators

    If the fingerprint no longer matches, it falls back to semantic locators — finding the element by its role, label, or accessible name, the way a human or screen reader would identify it.
  3. Broader resolution

    Further fallbacks widen the search using the step's intent and the surrounding context, so a moved or restyled element can still be found.
  4. Heal and record

    When the element genuinely changed, the agent heals the step — figuring out the new way to reach the intent — and records the fix so it sticks.

Because the cheapest, most exact match is tried first, healthy tests stay fast; the heavier reasoning only kicks in when the page actually changed.

The healing corpus flywheel#

Every time the agent heals a step, it doesn't just patch that one run — it records the fix to a healing corpus. That accumulated record of "this change meant that fix" feeds back into future runs, so the next time a similar shift happens, BugBrain resolves it faster and more confidently.

This is a flywheel: the more your app changes and the more BugBrain heals, the more resilient your suite becomes. Maintenance work that used to land on a person increasingly gets absorbed by the system.

Deterministic export to Playwright#

Self-healing doesn't mean you're locked into magic you can't inspect. BugBrain compiles steps deterministically into exportable Playwright TypeScript — real, readable test code. "Deterministic" means the same IR steps plus the same locator cache always produce the exact same code; there's no randomness in the output.

So you get both: tests that heal themselves while they live in BugBrain, and the option to export clean Playwright code whenever you want it in your own repository.

Why semantic locators are sturdy

Finding an element by its role and accessible label (how a screen reader sees it) is far more stable than matching a generated class name — and it doubles as a nudge toward accessible markup. Tests that resolve this way tend to break less.

Frequently asked questions

What makes a test self-healing?

BugBrain stores each step as semantic intent — what to do, not a brittle CSS or XPath selector. At run time it resolves the step through a layered fallback, so a renamed class or moved element doesn't break the test. When something does shift, the agent heals the step and records the fix.

Won't my tests break every time the UI changes?

That's the maintenance burden self-healing is designed to remove. Because steps describe intent rather than exact selectors, most UI tweaks resolve automatically; when a change is bigger, the agent heals the step instead of failing outright.

Can I still export real code?

Yes. Steps compile deterministically to exportable Playwright TypeScript — the same intent plus the same locator cache always produces the same code, so you can take it with you.

What is the healing corpus?

It's the record of every fix the agent makes. Each healed step feeds back so future runs resolve the same kind of change faster — a flywheel that makes your suite more resilient over time.