
June 16, 2026

TestInspector reduces flaky test maintenance by automatically retrying failed tests with AI-suggested element selectors when the original selector no longer matches the DOM. When a test step fails because a CSS class was renamed or a developer changed the HTML structure, the self-healing engine analyzes the current page state, proposes alternative selectors, and re-runs the failing step without manual intervention. This eliminates the most common maintenance task in UI test automation: updating selectors after routine front-end changes.
The most common source of test failures in UI automation is not a defect in the application — it is a change in the DOM structure that invalidates a selector. A developer renames a CSS class, reorders elements in a component, replaces an id attribute with a data attribute for better semantics, or upgrades a UI framework that changes how elements are rendered. The test logic is still correct. The expected behavior is still present. Only the address used to find the element has changed.
This type of failure is called a brittle test or a flaky selector failure. It is distinct from genuine application defects and requires no product decision — only selector maintenance. In teams running large test suites, selector maintenance can consume a significant portion of QA engineering time, particularly during active frontend development sprints where UI components are frequently modified. For context on the cost this creates, see the software testing cost and pricing guide.
TestInspector's self-healing feature is controlled by the auto_retry flag on each test. When auto_retry is enabled and a test step fails with a selector error, TestInspector does not immediately mark the test as failed. Instead, it triggers a secondary analysis pass that attempts to locate the intended element using alternative strategies: matching by visible text content, by ARIA role and label, by element type and position in the DOM tree, and by attribute similarity scoring against the original selector.
The self-healing engine generates candidate selectors ranked by confidence. The highest-confidence alternative is used to re-run the failing step. If the re-run succeeds, the test is marked as passing with a notation that a selector substitution was made. The substitution is logged alongside the test run output so engineers can review the suggested replacement and decide whether to persist it as the new canonical selector. This gives you automated recovery in CI with informed control over what gets committed as the permanent fix.
For a broader view of how TestInspector structures test automation, see TestInspector's AI test automation platform and the test automation services Astaqc provides for teams building or scaling automation programs.
Flaky tests are not only caused by selector drift. A second common cause is environment-specific configuration: tests that fail in CI because credentials, URLs, or API keys differ between environments. TestInspector addresses this through a structured variable interpolation system that resolves values at runtime rather than hardcoding them into test steps.
Variables follow a three-level hierarchy: test-level variables, suite-level variables, and organization-level variables. At runtime, TestInspector resolves {{VARIABLE_NAME}} tokens in step targets and values by checking each level in order, with test-level values taking precedence. Test and suite-level variables are stored encrypted using AES encoding at rest, ensuring that credentials never appear in plaintext in the database.
Beyond named variables, TestInspector supports dynamic tokens for common patterns: {{TIMESTAMP}} resolves to the current Unix timestamp (useful for generating unique email addresses or order references), {{ALPHANUMERIC}} resolves to a random alphanumeric string, and {{TOTP:secret}} generates a time-based one-time password from a provided TOTP secret, enabling automated testing of MFA-protected flows without storing the OTP as a static value.
This variable system eliminates a second class of flaky test: the test that passes locally with hardcoded credentials but fails in CI because the environment differs. See Astaqc's software testing services for guidance on test environment strategy, and the complete guide to software testing for broader context on test reliability.
Self-healing is configured at the individual test level via the auto_retry flag. When enabled, TestInspector maintains a retry counter per test. If a step fails with a selector error, the engine attempts the self-healing recovery pass. If recovery succeeds, the counter is incremented and the run is logged as healed. If recovery fails after exhausting candidate selectors, the test is marked failed with full diagnostic output including the original selector, the candidate selectors attempted, and the specific DOM state at the time of failure.
Test runs stream live results via WebSocket, so engineers watching a run in the TestInspector dashboard see selector recovery events in real time. This transparency is important: self-healing recovery should be treated as a signal that a selector needs updating, not as a permanent solution. The goal is to prevent a single routine front-end change from causing a test suite regression in CI, not to defer selector maintenance indefinitely.
| Scenario | Without Self-Healing | With TestInspector Self-Healing |
|---|---|---|
| Developer renames a CSS class | Test fails in CI; engineer investigates, updates selector, reruns | Test recovers automatically; selector substitution logged for review |
| UI framework upgrade changes rendering | Multiple tests fail; triage required to identify affected selectors | Recovery attempted per test; failures isolated to genuinely broken flows |
| New team member breaks selectors accidentally | PR blocked; manual fix required before merge | CI passes; review surfaces suggested selector updates post-merge |
| Application logic defect (not a selector issue) | Test fails; engineer investigates | Test fails; self-healing does not apply — real defects surface normally |
| Intermittent timing failure | Test flakes; false negative reported | Auto-retry handles transient timing; persistent failures flagged |
Self-healing is effective for selector drift — the class of failures caused by DOM structural changes that do not reflect application defects. It is not a substitute for well-designed tests. Tests that rely on position-based selectors (the third div inside a container), on generated class names that change on every build, or on deeply nested element chains without stable anchor points will continue to produce unreliable recovery suggestions because there is no stable signal for the healing engine to latch onto.
The most self-healing-resilient tests use selectors in this priority order: id attributes (most stable), data-testid or data-cy attributes added specifically for automation (stable by contract), ARIA roles and labels (stable unless accessibility structure changes), visible text content (stable unless copy changes), and CSS class selectors (least stable in codebases using utility-first or CSS-in-JS approaches).
For teams looking to build a selector strategy from the ground up, Astaqc's QA team services and manual testing services provide hands-on support for test architecture decisions.
No. Self-healing applies the recovered selector for the current run only. The original selector remains in the test definition. The suggested replacement is surfaced in the run log for engineers to review and apply manually. This keeps the audit trail clean and ensures no selector change is made without human review.
TestInspector runs tests via Selenium on Chrome, Firefox, Edge, and Safari. Self-healing applies to all four browsers because the healing logic operates at the DOM analysis level, independent of which browser is executing the test.
Yes, with caveats. TestInspector supports explicit wait conditions via step commands like assertElementPresentUntil, which waits for an element to appear before proceeding. This handles SPA navigation latency. Self-healing then addresses selector drift separately from timing issues. The two mechanisms are complementary.
Each healed step produces a log entry recording the original selector, the alternative selector used, the confidence score, and whether the step passed on recovery. These logs are accessible in the TestInspector test run history and can be reviewed after the run completes.
Self-healing applies to UI element interaction steps. API request steps — requestGET, requestPOST, and related commands — do not depend on DOM selectors and therefore do not benefit from or require self-healing. For API step reliability, the variable interpolation system handles environment differences.
When recovery is not triggered, there is no meaningful overhead. When a selector failure triggers recovery, the additional time depends on the number of candidate selectors evaluated. In practice, a healing pass on a typical web page takes seconds — faster than the alternative: a failed CI run followed by manual investigation and re-execution.
Self-healing test automation is not a replacement for good selector design. It is a safety net that keeps your CI pipeline green while your team reviews and commits improved selectors at their own pace.

Sign up to receive and connect to our newsletter