Table of Contents
Related Blogs
It is the end of the day, and the testing team is packing up and heading home. As the last person out traditionally shuts off the lights, there is one additional task to complete. On the way, out one of the team members needs to trigger the nightly test run as part of their regression testing for mobile devices. The next morning, however, to the shock and dismay of the team, they discover that many of their tests have failed due to a locator change within the application.
These types of changes happen often and go unnoticed for a variety of reasons. A quick example would be that the Development team made a change that was so small that it was seen as insignificant and, therefore, not communicated to the QA Team.
The time and effort needed to review failed scripts, update locators, and rerun tests can quickly derail a sprint, increasing the risk of shipping defects into production.
In a world where AI is increasingly central to the SDLC, developers now receive assistance with contextual suggestions, code optimization, and even unit test generation. While this accelerates development, it can create downstream challenges for QA teams as they struggle to keep up with the increase in code created.
Minor UI changes like the one above often impact automated end-to-end tests. However, with the integration of AI Self-Healing, scripts can adapt on the fly, repairing broken locators mid-execution without disrupting the testing flow. This capability will help QA teams keep pace with rapid development cycles, significantly reduce test maintenance time, and provide faster feedback—all while increasing test resilience.
This blog will explore how AI-powered Self-Healing autonomously addresses element mismatches at runtime without human intervention.
Prerequisites: This feature is only available to Pro & Premium SaaS customers
To help you better understand AI Self-Healing and how it behaves on our platform, we will look at Digital.ai’s Banking Application built for Android and walk through a simple test for the Login Page where a change will be detected.
We will have two versions of the same Application, one unmodified (a build that is expected to work) and one modified (where one of the locators has been changed).
In the unmodified version of the Application, we see the ID “usernameTextField” identify the username locator:
This locator will be referenced in the automation script as shown below. The following lines validate and interact with the username field after the automated Appium tests are triggered:
``` wait.until(ExpectedConditions.elementToBeClickable(By.id("com.experitest.ExperiBank:id/usernameTextField"))); driver.findElement(By.id("com.experitest.ExperiBank:id/usernameTextField")).sendKeys("tester01"); ```
Under normal circumstances, where locators are not modified, the script would pass without issues.
However, let’s consider a scenario where the locator for the username field has changed. Instead of “UsernameTextField,” it is now identified as “UserTextField” in this modified build:
In this case, the script would fail immediately with a ”NoSuchElementException”.
How Can We Address This Issue?
``` DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability("testName", "login_scenario_test”); caps.setCapability("accessKey", ACCESS_KEY); caps.setCapability("deviceQuery", "@os='android'"); // https://docs.digital.ai/bundle/TE/page/device_queries.html caps.setCapability("app", "cloud: com.experitest.ExperiBank/.LoginActivity"); caps.setCapability("appPackage", "com.experitest.ExperiBank"); caps.setCapability("appActivity", ".LoginActivity"); desiredCapabilities.set(caps); driver.set(new AndroidDriver(new URL("https://<your_cloud_url>/wd/hub"), caps)); ```
Now, just adding the following line within your capabilities will tell the script it should run in a Self-Healing mode:
``` caps.setCapability("selfHealing", true); ```
You can now run the automated scripts as usual. No additional changes are required, whether from your IDE (such as Eclipse / IntelliJ) or a CICD pipeline (E.g., Azure DevOps).
Does Enabling AI Self-Healing Impact Regular Test Execution Time?
``` driver.executeScript("seetest:client.stopHealing"); ```
And when you want to resume, simply invoke another one-liner:
``` driver.executeScript("seetest:client.startHealing"); ```
Is Self-Healing Customizable?
- Recovery Tries: Defines the total number of attempts the algorithm will make to discover a matching locator.
By default, Self-Healing tries to identify locator changes once per element. For example, if the algorithm fails to find a replacement locator for the username field, it will only attempt it once before moving on. - Score-Cap: Sets a matching score threshold based on the probability of a successful match. The default score is set to 0.6 on a scale of 0.1 to 1.0.
A score of 0.6 indicates that Self-Healing will be triggered for newly identified locators only when the probability of a match is greater than 60%.
The Digital.ai Support Team can modify both of these properties upon request.
Does AI Self-Healing Work on All Types of Mobile Applications?
What Happens if Multiple Locator Changes Occur During a Single Test Script Execution?
My Tests Healed: Do I Continue Running My Tests as Is, or Do I Need to Modify My Scripts?
Why Heal if I Need to Make the Changes Anyway?
How Do I Know If Something Healed?
``` https://<your_cloud_url>/reporter/reporter/tests ```
Alternatively, on the main platform, click on your initials in the upper right corner and select “Go to Reporter”:
And go to the “Tests” tab:
This view will display all the executed tests for your project, including the percentage of tests that were healed:
Clicking on the Healed status in the pie chart will filter the results to display only the tests that were healed:
You can also click on each report to view detailed information about what was healed:
Final Thoughts
See Digital.ai Continuous Testing in Action
Explore
What's New In The World of Digital.ai
Cross-Browser Testing for Mobile Devices
Enhance your mobile app’s performance with our guide to cross-browser testing. Understand the challenges, tools, and best practices for proper UX.
Make Appium Script Maintenance Effortless with AI-Powered Self-Healing
AI-powered Self-Healing enhances mobile testing by autonomously fixing locator changes during execution, ensuring seamless test automation & reliability.
Testing and Evaluating Accessibility for Websites
Learn the essentials of web accessibility testing, including legal standards, benefits, and practical tools to enhance user experience for individuals.