WebDriver 页面等待

selenium2.4.0版本提供了页面等待处理。

显示等待元素可见:

1 protected void WaitElementVisible(By by,int timeOutInSeconds,
2             long pollingInterval) {
3         WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
4         wait.pollingEvery(pollingInterval, TimeUnit.MILLISECONDS);
5         wait.withMessage(String.format("Timeout waiting for element: %s", locator));
6         wait.until(ExpectedConditions.visibilityOfElementLocated(by));
7     }

 

隐式等待:

1 protected void Waitfor(By by,int timeOutInSeconds,
2             long pollingInterval) {
3         driver.manage().timeouts().implicitlyWait(timeOutInSeconds, TimeUnit.SECONDS);
4     }

 

posted @ 2015-02-10 08:33  悟空救我呀  阅读(209)  评论(0编辑  收藏  举报