Locators in Selenium

November 8, 2017
Category: Selenium

Selenium identifies the elements in the application to be worked on using the 8 locators.

Those are Id, Name, ClassName, TagName, LinkText, Partial LinkText, Css Selector & xPath.

Id Locator:

Id is unique for each and every element so it is common way to locate elements using ID Locator.
Id locators are the fastest and safest locators out of all locators.

Example:
driver.findElement(By.id(“User”)).sendKeys(“Test”);

In the above example we have identified ‘Username’ editbox using id locator