Finding objects or elements in Webpages is the main job while coding with Selenium.You can get Locators from here by which you can uniquely locate your elements in webpage.
This post talk about the priority of choosing the locator. You can think about mandatory and assistive properties to uniquely identify an object in Webpages.
Ads code goes here
The different locator can be..
- Class Name
- Tag Name
- Link Text
- Partial Link Text
Here is a pyramid or thumb rule to determine the mandatory properties to select locators that can uniquely determine an element in the webpage.
Try to get id/Name first to identify an object using developer console. If developer has not provided these then go for Secondary locator that is Xpath,CSS,Index etc to identify an object or element uniquely. If you fail to get first 2 then go with Composite locator or assistive locator to determine an object or element uniquely.
Let me know if you like the post. Please share this if you liked it. Also please feel free to comment.