Locating strategy by XPath

XPath is the standard for navigation tool for XML. We know that HTML is an XML document (xHTML). So you can use XPath to locate the HTML. See the below syntax.

To know more about XPath Locator, follow this link <Link of XPath>

driver.findElement(By,xpath(“XPath of the element”))

Scenario with Example:

import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.chrome.ChromeDriver;   
public class Locator_By_ID {   
public static void main(String[] args) 
WebDriver driver= new ChromeDriver() ; 
login_button= driver.findElement(By,xpath("XPath of the element"))

Leave a Reply

Your email address will not be published. Required fields are marked *