在隐式等待的情况下,如果 WebDriver
没有立即找到元素,它将等待指定的时间,如果在指定的时间过后未找到元素,它将引发异常。
表示在隐式等待的情况下,WebDriver
检查元素两次(最大值):
但是在显式等待的情况下,检查条件的频率是多少?
我的意思是,如果它每秒检查条件是否为真/不为空,或者只检查两次,比如隐式等待?
默认情况下,它每500毫秒检查一次(即轮询)。所以从源代码中你可以看到-
公开final staticDEFAULT_SLEEP_TIMEOUT=500;
public WebDriverWait(WebDriver driver, long timeOutInSeconds) {
this(driver, new SystemClock(), Sleeper.SYSTEM_SLEEPER, timeOutInSeconds, DEFAULT_SLEEP_TIMEOUT);
}
它在内部调用-
protected WebDriverWait(WebDriver driver, Clock clock, Sleeper sleeper, long timeOutInSeconds,
long sleepTimeOut) {
super(driver, clock, sleeper);
withTimeout(timeOutInSeconds, TimeUnit.SECONDS);
pollingEvery(sleepTimeOut, TimeUnit.MILLISECONDS);
ignoring(NotFoundException.class);
}