Multiple ways to web locate element

For writing automated UI test with Selenium, locating web elements is crucial.

For locating a web element, use browser developer options or extensions.
Google Developer Tools for Chrome and Firebug for Firefox is what I use.

WebDriver API provides many ways to locate elements.

Elements can be found using ID, Name, Link text, Partial link text, Class name, tag name

The recommended order of using them are 
1. Id — fastest and easiest in my opinion
2. Name — name of a button for example
3. Classname — css class name 
4. Xpath — I frequently used this and this can either be auto generated or created
5. Linktext — The a tag’s link test is a good way to locate web elements
6. Partial link text — Used in case when certain parts of link text tends to change
7. Tagname — Locating elements with HTML tag names. One of my favourite.
8. CSS selector — Popularly used when you want to select a particular element from a list.

Checkout next part for usage and examples.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.