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 -
- Partial Linktext
- Tag Name
- Class Name
- DOM Locator
- CSS Selector