Best Practices for Choosing Locators for Selenium

Wednesday, September 26, 2018

A question that comes often, especially by folks that are new to Selenium, is what are the best practices to use when choosing a locator for an element. In other cases, people just have bad habits and don’t even think to ask this question, but they encounter instabilities or maintenance problems, without knowing that they don’t use the locators effectively. For the sake of clarity, a locator is the combination of the type and the value of the By clause which Selenium WebDriver uses in the FindElement and FindElements methods. As you probably know (given you’re familiar with Selenium), Selenium...