[英]Best way to wait until prices load completely (such as on comparision websites)
I tried using implicit wait but it did not work somehow and then I also tried explicit wait such as sleep
but again it did not work and also not a good practice.我尝试使用隐式等待,但它以某种方式不起作用,然后我也尝试了显式等待,例如sleep
但它再次不起作用,也不是一个好习惯。 I then looked at fluent wait but because I am using the PageFactory
and old version of fluent wait is deprecated, does anyone know how can I implement fluent wait along with PageFactory
.然后我查看了 fluent wait 但因为我使用的是PageFactory
并且不推荐使用旧版本的 fluent wait ,有谁知道我如何与PageFactory
一起实现 fluent wait 。
Here you go...干得好...
public static void waitForElement(WebElement element){
try {
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(Duration.ofMillis(60000))
.pollingEvery(Duration.ofMillis(1000))
.ignoring(NoSuchElementException.class)
.ignoring(StaleElementReferenceException.class);
wait.until(ExpectedConditions.elementToBeClickable(element));
waiting(100);
//can add further action here
} catch (Exception e) {
e.printStackTrace();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.