Optimize Process

Optimize Scripts by itself does a self-healing as well in the following ways:

The initially selected locator will be used in the first execution of the optimization process to find any new locators. Any non already existing locators found will be added to the list of locators to test during the optimization process. This finding of new locators is done only in the first execution, so proper weight calculation can be used to compare the available locator to find the most stable one. It also removes accessors that did not work less than 3 times (0, 1, 2)
In the case of tied weights for several locators, the original order present in the step will be maintained as a recorded script does not have a way to identify if a given accessor is an id, a class, a text, etc., so will not be able to apply accessor preferences ordering as part of the optimized process.


This feature is helpful when you are not sure of what accessor preference to set upfront, just record the script with default accessor preferences, and Optimize script will help you set the right one for each of the steps based on how many times it was found and how much weight-age was given for each of the accessors for each of the steps


Note: To make use of Optimize, it is good to record the script enabling Xpath Search from the Options menu as well.

  1. Create or open an existing script to optimize. Below is one example script that was recorded with the default Accessor preferences option

  2. Right-click the steps are to open the context menu options, choose to Optimize, and choose any browser in the list

  3. Once the browser is chosen, the script would be played back 5 times picking the right accessor each time from the list of accessors and at the same time giving weights to each of the accessors

In the logs section, you would notice that the Optimization execution number shows 5, and also you could notice that the script's accessor has been changed to a different one compared to what it had recorded.

On each execution, the accessor weights will be added per each step of the script. If you wish to cancel the process, you can simply close the browser that is executing the script.

There might be cases where index-based accessors have the greater weight, so that should be the right accessor to set even if it is index-based, so this method does not exclude index-based accessors as fallback-accessor does.

Below is the weight rules that is defined:

accessor + ordinal position --> 5 points

  • link(0)

  • textbox(0, _in(div("login"))

byXpath ex:

  • byXPath('//*[text()="demo"]') --> 7 points (contains text(), @id, @name

  • byXPath others --> 5 points

others: 10 points

  • link("demo")

  • textbox("username")

  • mySmartTag("myName")

the element was not found: 0 points