public static Boolean waitElementIsEnabledBy(WebDriver driver, By by) {
try {
WebDriver waitDriver = driver;
//如果存在立刻执行点击动作,如果不存在,超出20s后则抛出异常,返回false
long waitTime = 20;
waitDriver.manage().timeouts().implicitlyWait(waitTime, TimeUnit.SECONDS);
(new WebDriverWait(waitDriver, waitTime)).until(ExpectedConditions.elementToBeClickable(by));
return true;
} catch (Exception e) {
return false;
}
}
智能等待
最新推荐文章于 2023-07-11 13:03:01 发布