find element by xpath selenium java code example
Example 1: get element by xpath
document.evaluate('XPATH HERE', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
Example 2: how to find selenium webelement java
WebDriver driver = new ChromeDriver();
WebElement objWE;
objWE = driver.findElement(By.id("String of id attribute"));
objWE = driver.findElement(By.xpath("//*[@id="search"]/div[2]/div[6]/div[1]/div/div"));
Example 3: findby(xpath selenium java)
@FindAll(@FindBy(how = How.XPATH, using = "//a[@class='fNiv' and contains(text(), 'Home')]"))
List<WebElement> allElements;