

It is also applicable if any one of the condition is true, or maybe both. OR expression uses two conditions, whether the first condition OR second condition should be true. List elements = driver.findElements(By.xpath(“//h1/parent::form//h2”)) Below is the syntax to use ‘contains’ function within the XPath. The syntax for locating elements through XPath- Using contains() method can be written XPath- contains() method, we can write the Java code along with the dynamic XPath location the ‘contains’ function, we can extract a list of web elements containing the matching text throughout the web page.

