Know more about locators in Selenium - selenium webdriver tutorials

Currently, Selenium is the undisputed leader among all test automation tools on our planet earth. According to industry watchers, it will remain as the leader for quite some time as it has many attractive features which many of the competitor test automation tools do not have.

  • Selenium is free and open source software. This helps to save in the cost of purchasing the license and hence the testing expenditure  can be reduced considerably.
  • Selenium is compatible with multiple platforms including Windows and Linux so the people who are comfortable on different platforms can use it easily.
  • Selenium is compatible with multiple browsers including Mozilla Firefox, Google Chrome, Internet Explorer etc. Hence people who are comfortable with different browsers can use selenium easily.
  • Selenium supports multiple programming languages including java, C#, Ruby, Python, PHP etc. Hence, there is no need to learn a new programming language if you know any of the programming languages that is supported by selenium.

Apart from all these features, selenium is easy to learn and easy to work with. Test execution is a very simple process in selenium when compared with other test automation tools. Locators in selenium are used to find and match elements in the page that need to interact for executing the tests. This is an easy process and there are several types of locators available in selenium to find the elements.

  • Identifier
  • ID
  • Name
  • Link
  • DOM
  • XPath
  • CSS
  • UI-element


It works with id and name attributes of HTML tag. This easily matches many elements but does not depend on the structure of the page. It will work even if the structure has changed.


This locator facilitates locating an element by ID. As the ID is unique for each element there will not be any chance for matching with any other element. At the same time, it matches elements with a fixed ID only and not with generated ID.


This locator allows locating an element by name. This is advisable for fixed list of similar elements and not good to use with data bound lists


This locator is for locating an element by a link. This is the best option when you are testing navigation but you should know the text of the link before using this locator.


This locator helps you to locate an element that matches with the javascript description of the element in the DOM page.


XPath selector is used to locating elements in XML documents and can be used wherever there is an XML. However, it is slower than many other locators.


Here, CSS selector is being used to locate elements in the page. They are much faster and most widely used but the process is a bit complicated.


UI element is comparatively a new locator which was an extension of Selenium IDE earlier.

These locators will make locating elements easier and thus reduce the time consumption for the execution of tests.

Leave a Reply

Your email address will not be published. Required fields are marked *