Key differences between Selenium and Silk: Robust locators

Micro Focus Expert
Micro Focus Expert
1 0 745

Generating good locators for elements in web automation is extremely hard, but also very important. Good locators ensure that your tests don't break every time a small change is applied to the application, but also need to hit the expected elements and nothing else. Modern testing tools come with a variety of strategies to locate elements, including XPath, CSS, and image-based mechanisms, which adds an extra layer of complexity.

Let's look at how testers address that challenge using Selenium, Silk WebDriver and Silk Test.


Using plain Selenium, it's the testers responsibility to figure out the best locator for each element. Usually the developer tools of the browsers are a good starting point for that as they are capable of generating XPath and CSS locators for almost every element, though often those locators are more complex (and less maintainable) than they would need to be.

Consider the following example: Sure you could go with the XPath locator that the Chrome DevTools suggested, but a plain "By ID" locator would be much simpler:

Silk WebDriver

Silk WebDriver takes the burden of finding good locators away from the tester, as it automatically determines the best locator for each element. The "best" locator usually is the easiest locator that still matches the element. So in the aforementioned example, Silk WebDriver would automatically pick "By ID" as the locator, whereas in more sophisticated web apps XPath or CSS would be used.

Silk Test

Silk Test builds upon the capabilities of Silk WebDriver but allows for more sophisticated customization of the automatic locators. Also, users are not required to use the browser developer tools to locate elements and build locators, but it comes with a dedicated tool for that job: the so-called Locator Spy:


The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.