我正在尝试这样做:
@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);
}
}
}
但是在硒化物中
硒化物
@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;"));
}
}
}
测试通过但没有任何反应
这里用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();
}
}
}
它仅突出显示第一个弗洛里安
@Test
public void testFloriangg() {
$x("//table//td[text()='Florian']").highlight()
.findAll(By.xpath("//table//td[text()='Florian']"));
}
它也只突出了第一个弗洛里安,其他人则没有。我需要突出显示具有该名称的所有行。哪里有问题? 在此输入图片描述
我有 硒化物版本 7.2.1 硒版本 4.18.1 JDK 21
突出应有的一切
@Test
public void testFloriangg() {
$$("//table//td[text()='Florian']").forEach(e -> e.highlight());
}