Execute Test Cases in Self Healing Mode

Automation Testers use QAS to record test cases through web pages. The web pages change with time, which requires modification in scripts due to change in locators.

QAS has introduced the ability of self healing of scripts that would automatically get alternate strategies/elements to find out the locators without any manual intervention from testers. QAS will re-test the script and notify the user whether the suggested solution has worked or not. In case any of the alternate strategies/elements are unable to get the locators, QAS will give an option to users to fetch the correct locators at run-time.


The Self Healing feature is useful when the web pages, on which the test case is recorded, keep changing and so their locators are. If the Self Healing Mode is enabled, QAS does its best to automatically replace locators to run the test successfully. Even if the test fails, QAS gives the user an opportunity to select a suitable locator on the web browser and add it to the script directly. The test will run again automatically from where it failed which will make the test case "Pass".
The Self healing feature covers the following use cases:
  • During execution, if a test step locator is failed to be detected by its default locator value, the other locator strategies in the list will be automatically applied without any manual intervention from the tester. The execution will continue as if no failures has happened.
  • During execution, if a test step locator is failed and can't be auto detected using any of the other locator strategies, QAS will pause the execution, allow user to select the relevant element and continue the execution. The new locator strategy will be auto updated for the next execution.  


Note: The Self Healing Mode is only available when the test is being executed through the Chrome browser.


Once test objects in test cases are created by the recording feature in QAS, a set of  Elements will be generated. These different set of elements are identified as strategies.

The Execute in Self Healing Mode option is available when you go for the execution of the test case/test suite of a web project.

Execute in Self Healing Mode


1. Click on Execute above the grid and select Web.



The Execute in Self Healing Mode option is provided to enable the self-healing mode of script in case locator errors occur while test execution. The mechanism will try other strategies of locators if one fails. 


2. Select the Execute in Self Healing Mode option and click Start.



While executing the tests, there are three scenarios:

(1) If all Locators are found then the test is passed.

(2) If some of the locators from the recorded elements fails, then QAS will try to execute the test with already pre-recorded other strategies/elements and will try to locate the locators to pass the test.

(3) When all the recorded strategies are failed to locate the proper locators, QAS asks the user to select relevant locator on the web browser with the help of Object Spy. It will replace the existing locators accordingly.


For example, in the following images -

1. The test fails due to a missing element. The message indicates to find locator in browser.



2. The verification of locators is in-progress in QAS.



3. The verification of locators is in-progress in Web browser.



4. If QAS does not find suitable locators for the test, then it will ask the user to find the locator in browser using the Spy Object functionality.



You can get a quick help for keyboard shortcuts by clicking on the Help icon at the extreme top right corner.



5. Once you find the relevant element on the browser, click + button to add it to QAS.


6. The test elements are updated accordingly in QAS and the test runs a new resulting into successful run of the test case/test suite.


Locators Before Self-Healing


Locators After Self-Healing


Execute Steps in Debug Mode

Users can execute recorded steps in Debug mode for Web and Mobile Web projects. It allows users to add new steps in an existing test case during its execution. For example, a test case is recorded with some steps in the initial stage. Now testers want to add more steps as verification to the same test case. With the Debug Mode users can easily add steps to an existing test case during execution without recording the test case anew.

→ The debug mode is supported in Self Healing mode.

Note: If test data is being used in the test case, then the test steps will be executed for the first set of data parameter only.

Steps

1. Open the recorded test case.

2. Add a debugger point by clicking on the step number after which you want to add new steps during execution.



3. Click Execute > Web. The Execute Web pop-up opens. Make sure you select Execute In Self Healing Mode. Click Start.



4. A pop-up opens confirming about the insertion of the debug point. Click OK to proceed for the execution with debug mode.



5. The execution with debug mode is initiated.

6. The execution takes a pause after the step where you have inserted a debugger point.

7. The QAS recording gets started. You can record required steps at this point. Once you are done with recording, click on the blinking icon on the browser tab.



8. The execution mode resumes to execute the remaining steps in the test case to complete the execution process.



9. The steps that are added (recorded) while execution will have “Not Run” status as they are yet to be executed.



You can now execute your newly generated test steps in normal mode (i.e. without Self Healing) to check its workflow.


Self-healing in Mobile Test Recording

QAS supports Self Healing for mobile device executions for both iOS and Android platforms. The ability of self healing of scripts that would automatically get alternate strategies/elements to find out the locators without any manual intervention from testers. QAS will re-test the script and notify the user whether the suggested solution has worked or not.

There are two options available to execute test cases for the mobile platforms: Normal Mode and Self Healing Mode.



When the test is executed with Self Healing Mode, it will heal the broken elements, replace those elements with new locators and cause the test to pass.




View Self Healing Logs

Once you execute the test in Self Healing mode, you can view the logs under the Self-healing Insights. All the replacements of locators taken place during test case execution in Self Healing mode are recorded under Self-healing Insights once the execution is complete.

Click on the test case and select the Self-healing Insights option on the menu.



The Self-healing Insights screen opens.



The screen shows details of the Test Case name, the impacted command, which object and element were broken, which object and element were recovered, and replaced elements.

  • Test Case: Name of the test case during the execution of which the locators have been replaced through the Self- healing mode.

  • Command: The impacted Command in the test case code where the locators were replaced.

  • Broken Object: The object which the default locator could not detect during the test execution.

  • Broken Element: The element that could not be traced by the default locator during the test execution. 

  • Recovered Object: The object that is healed and located through the alternative locator during the execution in self-healing mode.

  • Recovered Element: The new/alternative locator found through self-healing mode during the execution.

  • Replaced Element: In case all the elements of the test case are failed, you need to find the new locators on the UI through the Object Spy functionality of QAS. The original elements are replaced by the newly found elements to run the test successfully. To view the details of replaced elements, click on the view the icon for the test case.


The element details - Old Elements and Replaced Elements are available to view by clicking on view the icon.