Kapi Shivhare
What are the different types of locators in Selenium?
By Kapi Shivhare in Software Testing on Nov 03 2016
  • Pavan R Bhupalam
    Mar, 2021 30

    Method Syntax Description

    By ID driver.findElement(By.id ())
    Locates an element using the ID attribute

    By name
    driver.findElement(By.name ())
    Locates an element using the Name attribute

    By class name
    driver.findElement(By.className ())
    Locates an element using the Class attribute

    By tag name
    driver.findElement(By.tagName ())
    Locates an element using the HTML tag

    By link text
    driver.findElement(By.linkText ())
    Locates a link using link text

    By partial link text
    driver.findElement(By.partialLinkText ())
    Locates a link using the link’s partial text

    By CSS
    driver.findElement(By.cssSelector ())
    Locates an element using the CSS selector

    By XPath
    driver.findElement(By.xpath ())
    Locates an element using XPath query

    • 1
  • Sanjeev Singh
    Jul, 2020 16

    Selenium supports 8 different types of locators namely id, name, className, tagName, linkText, partialLinkText, CSS selector and xpath. Using id is one of the most reliable and fast methods of element recognition. Usually, the id is always unique on a given web page

    • 0
  • Kapi Shivhare
    Nov, 2016 3

    Locator can be termed as an address that identifies a web element uniquely within the webpage. Thus, to identify web elements accurately and precisely we have different types of locators in Selenium:ID ClassName Name TagName LinkText PartialLinkText Xpath CSS Selector DOM

    • 0

Most Popular Job Functions