Understanding the Katalon Studio Self-Healing Mechanism
The Self-Healing Mechanism is a powerful feature offered by Katalon Studio, designed to tackle one of the most frequently encountered challenges in test automation – the dreaded NoElementFoundException. But, what causes the NoElementFoundException in the first place? This issue generally surfaces due to a failure in locating the test objects, incorrect implementation of locator strategies, or inability to load the chosen test objects into the Document Object Model (DOM). The good news is, Katalon Studio has effectively addressed this problem with its innovative self-healing mechanism.
Imagine the self-healing mechanism of Katalon Studio as an in-built system within the tool that is capable of automatically repairing itself. But before we explore how this feature can be practically applied, it's essential to understand the theoretical aspect of the self-healing mechanism and how it operates.
What is Self-Healing Mechanism?
The Self-Healing Mechanism continues to search for alternative options when a test automation script cannot find a test object. This way, instead of failing due to a NoElementFoundException, it continues with the scenario steps. Its primary goal is to mitigate the common problem of failing to locate test objects in test automation, thus enhancing the stability of test scenarios. It's important to note that currently, this mechanism is only employed in web-based automations.
Activating Self-Healing in Katalon Studio
The Self-Healing Mechanism is activated by default when creating a web-based project in Katalon Studio. You can verify its activation as follows:
During a web-based project setup in Katalon Studio, the Self-Healing Mechanism supports four test object methods:
You can choose to employ one or more of these methods by selecting or deselecting the corresponding checkboxes. Furthermore, you can prioritize the alternative methods using the up and down arrows, defining the type of test object it should first search for as an alternative. If left unchanged, it will select an alternative test object based on the default order.
By default, it will first attempt to find the test object using Xpath. If found, it proceeds with the following steps. If not, it will sequentially explore the other test object types, continuing the process with the test object that matches successfully.
Remember, these steps illustrate the default
behavior of Katalon Studio's Self-Healing Mechanism for a web-based project.
When Should the Self-Healing Mechanism Be Avoided?
The Self-Healing Mechanism is primarily intended for interacting with web objects. It's not suitable for verification or comparison methods. In such instances, you can utilize the Self-Healing menu to exclude methods that shouldn't be applied.
Applying the Self-Healing Mechanism
By employing alternative objects in place of unavailable test objects, all our tests have been successfully executed, as illustrated below.
During test execution, if a test object poses a problem, a SELF-HEALING warning will appear in the "Console" and "Log Viewer" tabs.
Upon test completion, the Self-Healing Insights tab will propose choices for alternative test objects. You can select the preferred test object in this section, as depicted below.
This tab displays the unavailable test object, the used alternative test object, the method used to locate it, and a screenshot of the element. You can amend the unavailable test objects in this section and designate a new test object.
The Self-Healing Mechanism provides a valuable framework for managing unfound web objects, thus ensuring test automation stability. To learn more about the Katalon Studio automation tool and discuss the testing solutions we offer for your applications, don't hesitate to contact out to us.