Sitemap
Metaforum Tech

Metaforum Tech

Element locators in Selenium

1 min readDec 13, 2017

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:

  1. Id
  2. CSS name
  3. Name
  4. Class Name
  5. Link Text
  6. Partial Link text
  7. Xpath
  8. Tag name

Note some important aspects of element locators:

  1. While both CSS selector & XPath are unique values, scripts that use CSS scripts are much faster than scripts that use XPath value.
  2. 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.
  3. 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.

--

--