Creating Stable Locators

One of the main advantages of Silk Test Workbench is the flexible and powerful object-recognition mechanism. By using XPath notation to locate UI controls, Silk Test Workbench can reliably identify UI controls that do not have any suitable attributes, as long as there are UI elements near the element of interest that have suitable attributes. The XPath locators in Silk Test Workbench can use the entire UI control hierarchy or parts of it for identifying UI controls. Especially modern AJAX toolkits, which dynamically generate very complex Document Object Models (DOMs), do not provide suitable control attributes that can be used for locating UI controls.

In such a case, test tools that do not provide intelligent object-recognition mechanisms often need to use index-based recognition techniques to identity UI controls. For example, identify the n-th control with icon Expand. This often results in test scripts that are hard to maintain, as even minor changes in the application can break the test script.

A good strategy to create stable locators for UI controls that do not provide useful attributes is to look for an anchor element with a stable locator somewhere in the hierarchy. From that anchor element you can then work your way to the element for which you want to create the locator.

Silk Test Workbench uses this strategy when creating locators, however there might be situations in which you have to manually create a stable locator for a control.