Some websites don't like to be scrapped and in that case you need to disguise your webscraping bot as a Human Being.
Locator can be termed as an address that identifies a web element uniquely within the webpage. Locators are the HTML properties of a web element which tells the Selenium about the web element it need to perform action on.
There is a diverse range of web elements. The most common amongst them are:
Text box Button Drop Down Hyperlink Check Box Radio Button
Types of Locators in Selenium
Photo Credit - www.softwaretestinghelp.com
XPATH
Xpath is used to locate a web element based on its XML path. XML stands for Extensible Markup Language and is used to store, organize and transport arbitrary data. It stores data in a key-value pair which is very much similar to HTML tags. Both being mark up languages and since they fall under the same umbrella, xpath can be used to locate HTML elements.
The fundamental behind locating elements using Xpath is the traversing between various elements across the entire page and thus enabling a user to find an element with the reference of another element.
CSS-Selector
CSS Selector is combination of an element selector and a selector value which identifies the web element within a web page. The composite of element selector and selector value is known as Selector Pattern.
Photo-Credit - www.softwaretestinghelp.com
Primitive types of CSS Selector