I am trying to locate the element div based on its descendant text nodes.
Below is the HTML:
<html><head></head><body>
<div>
<div class="d x">Foo</div>
<span>Mumbai</span>
<h1>DEF</h1>
</div>
</body></html>
Selenium code:
driver.findElement(By.xpath("//div[.='FooMumbaiDEF']"));
As per my understanding and after referring to the stackoverflow posts, Testing text() nodes vs string values in XPath the string-value of an element node is the concatenation of the string-values of all text node descendants of the element node in document order.
But I am getting NoSuchElementException: Unable to locate element: //div[.='FooMumbaiDEF']
Any idea why it is not able to find an element ?