LambdaTest Community

Find answers, support, and inspiration from other users

Questions
LambdaTest Community
Answered

What do you mean by locators in Selenium? What are their types?

Lately i have been confused about the meaning of locators in selenium and about their types, can anyone please guide me onto it.

Up Vote Down Vote 0 Votes
Posted 4 months ago

Answers


Locator in selenium context, are the strategies used to locate/ identify various WebElements.

Locator is a command that tells Selenium which GUI elements ( say Text Box, Buttons, Check Boxes etc) its needs to operate on. Identification of correct GUI elements is a prerequisite to creating an automation script. But accurate identification of GUI elements is more difficult than it sounds. Sometimes, you end up working with incorrect GUI elements or no elements at all! Hence, Selenium provides a number of Locators to precisely locate a GUI element

Types of locators in the order of priority to be used are -

  • ID
  • Name
  • Linktext
  • Partial Linktext
  • Tag Name
  • Class Name
  • DOM Locator
  • CSS Selector
  • Xpath
Up Vote Down Vote 0 Votes
Posted 3 months ago
209 Views
1 Answer
4 months ago