I'm trying to use XPath to find an element containing a piece of text, but I can't get it to work....
WebElement searchItemByText = driver.findElement(By.xpath("//*[@id='popover-search']/div/div/ul/li[1]/a/span[contains(text()='Some text')]"));
If I remove the last bit with the "contains" thing, it locates my span element, but I need to select it based on the text contents. It's not going to be a perfect match of 'Some text' either, because it might contain truncated strings as well.
What is the issue?
a
element (and it's surrounding elements) so we can compare it's structure to what your XPath follows. – Espresso