Element locators in Selenium
Selenium is the most popular automation testing tool. (Read Software Testing training in Chennai). It is very important for a Selenium test engineer to select proper web element locators while writing and enhancing test cases. Because a proper element locator ensures robustness of the code. By proper element locators, we mean the ability of element locator to withstand changes in GUI or changes in properties of a GUI. Selenium provides considerable flexibility when it comes to element locators. In fact, there are 8 different element locators in Selenium and in our Selenium training in Chennai, we cover all of them. In this article, we will list out all element locators and provide a link to our detailed article regarding this topic.
Get Metaforum Tech’s stories in your inbox
Join Medium for free to get updates from this writer.
Types of Element locators:
- Id
- CSS name
- Name
- Class Name
- Link Text
- Partial Link text
- Xpath
- Tag name
Note some important aspects of element locators:
- While both CSS selector & XPath are unique values, scripts that use CSS scripts are much faster than scripts that use XPath value.
- While Link Text & Partial Link Text works in the same way, both are applicable only for hyperlinks. If there are same link text exists multiple time, first, one will be executed.
- Element locators ID & Name are suitable to test values that changes periodically like username & password.
For more details about element locators, read this article here.



