DEV Community

TestingNews for Katalon Platform

Posted on • Originally published at katalon.com on

Eliminate Object Locator Flakiness with Katalon’s New Self-healing Feature

Eliminate-Object-Locator-Flakiness-with-Self-healing-using-Katalon-Studio

In Web UI testing, testers have to deal with increasing new page objects and changing identifiers when the web application grows. No matter if you are a manual or an automation tester, updating object locators for the Application Under Test (AUT) is a required step when changes are made. This helps ensure regression testing flows without friction and all key functionalities are not affected.

Self-healing is a common solution provided by automated testing tools made to solve the challenge of constantly changing the UI of web applications. Self-healing capability offers a host of benefits for testers and their team: it takes less time and effort to ensure all the functional tests run smoothly and avoids interruption for all executions.

What is Self-healing Automation? Why Is It Important?

What-is-self-healing-automation-and-why-is-it-important

Self-healing is a mechanism made to solve the problem of identifying objects as the product evolves, and necessary changes are made. Offered by most automation frameworks in the market, Self-healing basically is automation for automation. Testing tools with self-healing are able to detect changes in the properties and automatically update with new attributes to ensure the designed test cases are functional.

In web testing, one common challenge is to deal with changes in the application under test as the product takes on another shape. Web UI testing can be considered an integral part of any web application product. It is what the users first experience, and it also reflects the quality of production for businesses. However, when the UI changes, test objects’ properties also change, causing the tests to fail later on.

When test scripts are easily affected by the rapid release and update of the product and its development team, test case maintenance becomes inevitable for testers. For both manual and automation testers, having to go back to old scripts and update new properties to each object is a daunting task, let alone the fact that Agile development is now the new norm.

The self-healing mechanism

When designing test scripts for Web UI testing, both low-code and code-driven practices, objects of the AUT are bound to a locator to run the test steps successfully. It is definite that the AUT will not stay the same over time, and each tweak or change made to the UI will be mismatched with the predesigned test cases.

Testers usually expect their test cases to fail as updates are constantly added unless they have had plans for maintaining the test scripts despite future changes — by employing a self-healing mechanism.

Automation frameworks build the self-healing capability as a “smart” feature that makes testing easier for teams. To avoid failed test cases, the test automation tool will apply the new object’s locators and ensure the entire script stays up-to-date with each change made to the product’s design.

Why Self-healing is important and its benefits to the testing team

Self-healing is the key to build an efficient maintenance process for automated testing. Without a doubt, with a well-planned out maintaining approach, testers free themselves from a heap of repeating tasks and never-ending edits in the test scripts.

  • Less failed tests

Your tests might fail, that’s no news to any tester, however sometimes the root cause of failures is simply that the UI changed and the test did not. With self-healing activated, tests are most likely to not fail due to the inability to detect the correct locator of the object — disrupting the flow of the whole project.

  • Prevent object locator flakiness

Flakiness in testing makes it hard for testers to identify whether or not their tests are stable. “NoSuchElementException” is one of the many errors that cause flakiness to the test design that testers cannot have much control over. By ensuring the test’s design stays updated with the app, executions flow more easily, seamlessly, with less tendency to fail when it is unable to detect the object.

  • Save time and effort of maintaining test scripts for teams

Failed test results prevent testers from gaining valuable insights on their tests, because the root causes may vary and do not reflect the real status and performance of the AUT.

Another important aspect of testing is to anticipate the users’ behavior and build a product that is ready for the unexpected. This does not sound simple, well, it truly is not. Self-healing takes away their concern for each time the UI gets updated: regression test cases have a high chance to fail, and eventually slow down the entire development flow.

The Self-healing Mode in Katalon Studio Enables Better Execution Performance

Apply-Self-healing-using-Katalon-Studio

Prior to Katalon Studio version 7.6, users are familiar with the Auto-healing Smart XPath plugin provided by the Katalon team. The plugin is made to recover the broken default locators for testing in batch overnight.

As a successor, the new Self-healing capability of Katalon Studio is an upgrade of the same principle, only better.

How Self-healing from Katalon helps make testing easier

Similar to the definition above, the Self-healing test mode in Katalon Studio is capable of determining test status, detecting errors, analyzing, and offering a solution to heal the broken test automatically. What’s left for our users is to approve the suggested solutions or deal with it themselves.

With Self-healing enabled, testing becomes truly automated — as expected from innovative automation tools. Katalon users can have fewer worries for each time they run test cases in batch overnight.

The Katalon team decided to develop Self-healing to reduce the effort for test maintenance significantly while ensuring quality with more efficient performance. In other words, the development team can rest assured that when test cases fail, they fail with good reasons, and those reasons can reflect the quality of your product.

How Self-healing works in Katalon Studio

Katalon Studio supports 4 selection methods for spying and recording Web UI tests. Spanning from XPath, Attributes, CSS, to Image, the user can prioritize the order of these selection methods for executions. As for the XPath method, you will need some extra settings to set up how Katalon will go through the remaining options when the test case fails.

How-Self-healing-works-in-Katalon-Studio

The Self-healing mode is enabled by default for your project. You can go to Project > Settings > Self-Healing > Web UI to open the Self-healing window, or click on the Self-healing icon directly from the toolbar. You can also exclude used objects with keywords to prevent Katalon Studio from retrying to locate the objects with self-healing mode.

After the test run, if Katalon Studio applied Self-healing to an object, it is shown in the Self-healing Insights tab. The updated locator for the test run is saved temporarily, and you need to approve this change to make it permanent.

Self-healing insight tab

In the Self-Healing Insights tab, it displays the following information:

  • Test Object ID : The ID of broken test objects.
  • Broken Locator : The default locator that couldn’t detect the object during execution.
  • Proposed Locator : The alternative locator that located the object during execution. The proposed locator is the newly generated smart XPath of that element if the object is found by using its screenshot.
  • Recovered By : The Selection Method that Katalon Studio used for detecting the object.
  • Screenshot : When finding an object with its alternative locator, Katalon would capture a screenshot of the test object for you to verify whether the found object is the wanted one. Click Preview to check the healed object.
  • Select : Decide which locator for you to take action.

See the full tutorial for Self-healing along with a sample project in Katalon Doc to best leverage this feature for your project.

Summary

Katalon users are most likely to be familiar with the concept of Self-healing through the Auto-healing Smart XPath plugin. The new Self-healing capability scales up the scope of this mechanism and makes handling broken locators in Web UI testing much more simple.

This feature reduces the maintenance task for teams, lowers the failure rate for test runs, and helps testers sleep better at night. With a smarter execution approach and automated mechanism, Katalon Studio is able to empower CI and CD for teams to accelerate faster with automation tools.

To see this feature in a demo presented by Katalon experts, hurry up and sign up for our upcoming webinar here

The post Eliminate Object Locator Flakiness with Katalon’s New Self-healing Feature appeared first on Katalon Solution.

Top comments (0)