I am trying to do this:
@Test
public void tableTest() {
getDriver().get(BASE_URL + "tabulka.php");
List<WebElement> rows = getDriver().findElements(By.xpath("//table//tbody//tr"));
for (WebElement row : rows) {
if (row.getText().contains("Florian")){
((JavascriptExecutor) getDriver()).executeScript("arguments[0].style.border='3px solid red'", row);
}
}
}
But in Selenide
Selenide
@Test
public void tableTestAi() {
ElementsCollection rows = $$("#table tbody tr");
for (SelenideElement row : rows) {
`if (row.getText().contains("Florian")){
row.shouldHave(Condition.attribute("style", "border: 3px solid red;"));
}
}
}
Test passed but nothing happens
And here test with highLight :
@Test
public void itShouldHaveFloriannm() {
ElementsCollection rows = $$("#table tbody tr");
$x("//table//td[text()='Florian']").scrollTo().highlight();
for (SelenideElement row : rows) {
if (row.getText().contains("Florian")){
row.scrollTo().highlight();
}
}
}
It highLights only first Florian
@Test
public void testFloriangg() {
$x("//table//td[text()='Florian']").highlight()
.findAll(By.xpath("//table//td[text()='Florian']"));
}
It highLights also only first Florian, the others not. I need to hightlight all rows with this name. Where is the problem? enter image description here
I have Selenide version 7.2.1 Selenium version 4.18.1 JDK 21