Skip to main content

AI-Powered Smart Heal for Automation Tests

Real Device

TestMu AI’s Smart Heal uses AI-powered algorithms to automatically detect and recover from locator failures during test execution. It intelligently detects missing elements, analyzes the UI in real time, and applies the closest valid match, keeping tests running smoothly despite UI changes. Both the original and recovered locators are logged for full visibility through the TestMu AI dashboard.

Smart Heal is currently in closed beta. To enable it for your organization, reach out via 24×7 chat or email support@testmuai.com.


Use Cases

  • Frequent UI Updates: When product teams ship fast and locator changes are common, Smart Heal prevents brittle tests from breaking on every release and make shipments fast.
  • CI/CD Reliability: Reduce flaky build failures by automatically recovering from locator issues in pipelines.
  • Maintenance Reduction: Spend less time fixing scripts manually and more time building new coverage.Deploy first and fix later.
  • Audit & Debugging: Use healed locator logs and screenshots to understand changes quickly and improve your scripts over time.

Smart Heal Workflow

  1. Baseline Creation Smart Heal requires at least one successful (Passed) test run to establish a baseline. On this initial run, TestMu AI captures a baseline snapshot of all element locators in your script. Make sure to include the TestMu AI Hook to explicitly mark tests as passed during execution.

    • The project name and test name must remain the same across runs for the baseline to apply.
    • Since Smart Heal uses AI-driven analysis, expect executions to take slightly longer than usual.
  2. Baseline Update After each successful test run, Smart Heal automatically updates your baseline to reflect the latest passed build. This ensures the most recent valid UI state is used as reference for future healing attempts.

  3. Detection and Healing In subsequent runs, if an element cannot be found due to UI or DOM changes, Smart Heal triggers automatically, leveraging AI-driven analysis of element attributes, hierarchy, and visual cues to find the closest valid match in the updated UI.

  4. Retry with Healed Locator When a likely match is found, the test step retries with the healed locator. These adjustments apply at runtime so the test flow continues without interruption. Both the original and healed locators are logged for full transparency.

  5. Fallback and Suggestions If Smart Heal cannot confidently identify an alternative, it records AI-driven suggestions in the dashboard. These insights help you quickly update or strengthen your locators to avoid repeated failures in future runs.


Smart Heal in Automation Tests

1. Upload Your App

Before enabling Smart Heal, ensure your app is uploaded to TestMu AI.

  1. Follow the Upload Your Application guide.
  2. Once uploaded, note the App ID returned by the API or dashboard.
  3. Use this App ID in the "app" capability in your automation script.

2. Enable Smart Heal with Capabilities

To enable Smart Heal, add "smartHeal": true to your desired capabilities in your Appium test script.

desired_caps = {
"deviceName": "iPhone 16",
"platformName": "iOS",
"platformVersion": "18",
"isRealMobile": True,
"app": "YOUR_APP_URL",
"build": "Smart Heal iOS",
"name": "Sample Smart Heal Test",
"smartHeal": True
}
tip

You can generate capabilities for your test requirements with the help of our inbuilt Capabilities Generator tool. For more details, please refer to our guide on Desired Capabilities in Appium.

3. Enable Smart Heal with Runtime Hooks

You can also control Smart Heal dynamically during test execution using runtime hooks. This is useful when you want healing active in specific phases or after major UI changes.

// Stop Smart Heal
driver.executeScript("lambda-heal-stop");

// Start Smart Heal
driver.executeScript("lambda-heal-start");

4. Running Your Tests

Once your app is uploaded and Smart Heal is enabled (either via capabilities or runtime hooks), execute your test script as usual with your preferred automation framework. Smart Heal will monitor for locator failures during the run, apply healing when possible, and log all details to the TestMu AI dashboard for review.


Viewing Results in Dashboard

Accessing the Dashboard

Your test results are displayed on the TestMu AI App Automation Dashboard.

Filtering Healed Builds

To display only healed builds, click on the Configure option at the top of the dashboard.

  • The following image shows the Configure box, with the Features tab highlighted:
    Smart Heal - Configure

  • When you open the Features tab, a pop-up appears where you can enable Auto-Heal to filter and display only executions where Smart Heal was applied:
    Smart Heal - Features Popup

  • Once filtering is applied, the dashboard highlights all healed elements in your tests. In this view, healed elements are marked clearly, while those that could not be healed are highlighted in red:
    Smart Heal - Highlighted Elements

Hovering Over Healed Builds

Each healed build has an associated icon. Hovering over this icon provides a tooltip that shows a brief summary of the session and the healing actions performed.

Smart Heal-2

Session Details

Access detailed execution logs that clearly differentiate between original and healed selectors, along with AI suggestions, and compare before-and-after screenshots. These insights help you understand how the Auto-Heal mechanism worked during execution and guide you in refining locators over time. Smart Heal - Session Details showing original and healed selectors

AI Review on Failures

When a test case fails, the dashboard provides AI-powered analysis and suggestions to help you quickly identify root causes and fix issues. Smart Heal - AI Review on test failure with suggestions

info

Smart Heal delivers the best results when applied to static components such as buttons or form fields, where locators remain relatively consistent across runs.

Test across 3000+ combinations of browsers, real devices & OS.

Book Demo

Help and Support

Related Articles