关于Wait
// WebDriverWait wait =(new WebDriverWait(session.getWebDriver(),10));
// wait.until(new ExpectedCondition<Boolean>(){// public Boolean apply(WebDriver d)
// {
// boolean loadComplete=false;
//// WebElement spanNextPage=session.getWebDriver().findElement(By.id("inbox_button_next_page"));
//// loadComplete = !spanNextPage.getAttribute("class").contains("a-button-disabled") || session.getWebDriver().findElement(By.id("inbox-page"))!=null;
// loadComplete=session.getWebDriver().findElement(By.id("inbox-page"))!=null;
// return loadComplete;
// }
// });

本文介绍了一种使用WebDriverWait结合ExpectedCondition实现的条件等待方法,该方法能够根据页面元素的状态来决定是否继续等待,有效避免了固定时间等待带来的效率问题。示例中展示了如何设置最长等待时间为10秒,并检查特定ID的元素是否存在。
1244

被折叠的 条评论
为什么被折叠?



