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


