线程等待方式
public void sleepTime(long time) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
隐式等待
public void implycitlyWait(int implicitlyWait) {
driver.manage().timeouts().implicitlyWait(implicitlyWait, TimeUnit.SECONDS);
}
显式等待
1等待元素出来
public void implycitlyWait(int implicitlyWait) {
driver.manage().timeouts().implicitlyWait(implicitlyWait, TimeUnit.SECONDS);
}
2等待元素有效
public void waitElementEnable(String locater) {
(new WebDriverWait(driver, 10)).until(ExpectedConditions.elementToBeClickable(By.xpath(locater)));
}
等待页面加载
public void pageLoadingTile(int pageLoadTimeout) {
driver.manage().timeouts().pageLoadTimeout(pageLoadTimeout, TimeUnit.SECONDS);
}