In this tutorial, we will learn how to find elements By XPath in Selenium Webdriver tests. XPath stands for XML path. It is the standard navigation tool and query language for XML documents. It is a very powerful language to express which element to target.
The Java syntax for locating elements using XPath is
The root element is identified by // . We can find elements with XPath by using Absolute Path or Relative Path.
For example to find all links on a webpage we can use the following Xpath expression:
List<WebElement> elements = driver.findElements((By.xpath(“//a”)));
Selenium Tutorials on this website: