By Locators Selenium Java?

The different locators in Selenium are as follows:
  1. By CSS ID: find_element_by_id.
  2. By CSS class name: find_element_by_class_name.
  3. By name attribute: find_element_by_name.
  4. By DOM structure or xpath: find_element_by_xpath.
  5. By link text: find_element_by_link_text.
  6. By partial link text: find_element_by_partial_link_text.

What is a locator in Selenium?

Locator is a command that tells Selenium IDE 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.

What are the 8 locators in Selenium?

We have 8 types of locators in Selenium Webdriver to find elements on web pages.
  • id.
  • name.
  • tagName.
  • className.
  • linkText.
  • partialLinkText.
  • xpath.
  • cssSelector.
Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.