LambdaTest Community

Find answers, support, and inspiration from other users

LambdaTest Community

What are the element locators available with Selenium?

Can anyone please provide me some guidance on the element locators available with Selenium, lately i am trying to gather some knowledge regarding it.

Up Vote Down Vote 0 Votes
Posted 4 months ago


Selenium uses what is called locators to find and match the elements of your page that it needs to interact with. There are 8 locators strategies included in Selenium:

  • Identifier : works with the Id and name attributes of your html tags.
  • Id : The Id strategy looks for an element in the page having an id attribute corresponding to the specified pattern.
  • Name : Like the Id strategy, but on the name attribute. You can also specify a filter to refine your locator
  • Link : The text of the link
  • DOM : The DOM strategy works by locating elements that matches the javascript expression refering to an element in the DOM of the page
  • XPath : While DOM is the recognized standard for navigation through an HTML element tree, XPath is the standard navigation tool for XML; and an HTML document is also an XML document (xHTML). XPath is used everywhere where there is XML
  • CSS : The CSS locator strategy uses CSS selectors to find the elements in the page
  • UI-element : new locator
Up Vote Down Vote 0 Votes
Posted 3 months ago