Self-healing

What is self-healing?

The "Self-healing" feature of the Execution Cloud makes sure that your tests will run smoothly, even if there are changes to web elements. Self-healing can automatically locate an element when its ID or other attributes have been modified, for example, if your test needs to click on a button with the ID "username", if the ID has changed, the Self-healing feature will still be able to locate the button based on other button attributes. To enable this feature, contact Applitools support.

Once Self-healing has been enabled for your account, the process is fully automatic and does not require any configuration or setup. If a test successfully runs with the help of Self-healing, you can view details of which steps in the test were run with the help of Self-healing.

How can self-healing help with the testing cycle?

  • Fewer tests fail during the navigation process

  • Prevents flakiness

  • Reduce test maintenance efforts and saves time

How does it work?

When you run a find element command on Execution Cloud, it records a variety of element data. For example, if you have a command to enter text in an element with ID "username", when the command runs, Execution Cloud records other element data, such as surrounding text, element size, position, and style class. If, in a subsequent run, the element ID has changed and Execution Cloud is unable to locate the element based on the ID, it looks for the element that most closely resembles the missing element based on other element data.

The process is self-healing and self-learning, this means that if a selector is not available to identify a screen element in a test and Execution Cloud substitutes it with a different selector (the "healed selector"), in future test runs, Execution Cloud will look for both the original selector and the healed selector when trying to locate the screen element.

For example, you may have a command to enter "Joe Doe" in a field with a classID "UserID". When Execution Cloud first enters text into this field, it records that the field with this classID also has the following attributes:

  • Field label: User Name

  • Text above field: Log in

  • Following field: Password

  • Font family: "Myriad Pro", sans-serif

  • Width: 100%

  • Background color: transparent;

  • etc.

If a web developer changes the classID, in traditional execution platforms, if the driver cannot find the classID, the test will fail. In Execution Cloud, if this classID no longer exists, it will look at all other elements on the screen to determine which element most closely matches the element that previously had the classID.

The result is that it is extremely rare for a test to fail, even if an element data has been changed. This process is fully automated, does not require manual setup or configuration, and is easy to maintain.

If an element such as classID has been modified, when Execution Cloud successfully identifies the element it records the updated classID so that it can use the new classID together with other properties in future tests.

Identifying self-healing events in the Eyes Test Manager

In the Test Manager, a test that passed with the help of the self healing algorithm is identified with a icon in the Batch list.

You can search for tests that passed with the help of the self-healing algorithm using the button.

To view details of the self-healing algorithm, in the Test results page, select a self healing test, and below the View toolbar, click the button.

This window includes details of the selector that failed and the selector which was used instead. In future test runs, Execution Cloud will use both the original selector and the new selector when trying to identify the screen element. Click the link to see details of the self-healing event, including when the event occurred.

Self-healing is enabled by default. To disable it, set the environment variable APPLITOOLS_USE_SELF_HEALING or the chromeCapability 'applitools:useSelfHealing' to false.

Defining Session names

To make sure that the Self-healing functionality in an Eyes test does not impact other tests, we recommend that you give each session a unique name.

As several Eyes tests can be performed together in a single Execution Cloud session, we recommend that you give a unique name for each session using the environment variable APPLITOOLS_SESSION_NAME or using Chrome capabilities applitools:sessionName.

If a session name is not defined, a name is generated based on the account and URL.