My goal is to achieve the following:
@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);
}
}
}
Now, I am attempting to accomplish this 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;"));
}
}
}
The test passes but nothing happens as expected
Here is a highLight test example:
@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();
}
}
}
However, only the first instance of Florian gets highlighted
@Test
public void testFloriangg() {
$x("//table//td[text()='Florian']").highlight()
.findAll(By.xpath("//table//td[text()='Florian']"));
}
In this case, all occurrences are not getting highlighted. I am using Selenide version 7.2.1 Selenium version 4.18.1 JDK 21