I'm trying to check if all td
tags contain specified text using xpath like:
WebElement tableId = driver.findElement(By.id("tablepress-6"));
if (!driver.findElements(By.xpath("//td[contains(text(),'" + textInput + "')]")).isEmpty()) {
List<WebElement> tdElements = tableId.findElements(By.xpath("//td[contains(text(),'"+ textInput + "')]"));
//...
}
Also I've tried methods using xpath like:
List<WebElement> tdElements = tableId.findElements(By.xpath("//*[contains(text(),'" + textInput + "')]"));
And like:
List<WebElement> tdElements = tableId.findElements(By.xpath("//tr[*[text() = '"+ textInput + "']]/td[2]"));
But if I check my website I'm not getting all matches for td
elements, maybe because of br
elements inside some of matched td
.
Instead of getting all 17
matches (like on the screen above), I'm getting less number of matches:
Can someone suggest me the way how to get all td
tags which contain specified text? Thanks in advance.