Reputation: 89
I am trying to make sure that the string I have searched is highlighted in the div, as sometimes it doesn't highlight all that I search for. The problem is, when it is highlighted I can't find it with
'//div[contains(text(), "' + text + '")]'
as the element is split.
Example of an highlighted element:
<span _ngcontent -c58 class="cli">
<span class="yellow-highlight">12</span>
"34567"
</span>
With the example, if I try to find "123" I won't find it as it doesn't contain that exact text.
Ideas?
**UPDATE:
Ended up creating 2 lists, one is made of "yellow-highlight" elements and one is just with the original text. If the size weren't a match I figured there must be a problem and the highlight didn't go as planned. Thanks :)
Upvotes: 0
Views: 114
Reputation: 2627
You may use this,
driver.findElement(By.XPath("*//span[normalize-space(contains(text(),'123'))]"))
Upvotes: 3