我需要等待属性收到值并得到关于“until”的错误。我做错了什么?谢谢
List<WebElement> messages = driver.findElements(By.className("message-item"));
//select last message
WebElement lastMessage = messages.get(messages.size() - 1);
//wait for last message attribute received failed
WebDriverWait waitLastMessage = new WebDriverWait(driver, 10);
waitLastMessage.until(lastMessage.getAttribute("data-deliverystatus").contains("failed"));
//here i check vaules of attribute
Assert.assertEquals(lastMessage.getAttribute("data-deliverystatus"), "failed");
答案 0 :(得分:0)
until
方法收到ExpectedConditions
,而不是boolean
。你可以做那样的事情(未经测试)
private ExpectedCondition<Boolean> waitForAttribute(final WebElement element) {
return new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver driver) {
return element.getAttribute("data-deliverystatus").contains("failed");
}
};
}
WebDriverWait waitLastMessage = new WebDriverWait(driver, 10);
waitLastMessage.until(waitForAttribute);