我需要验证页面是否刷新成功,或者页面每5秒刷新一次
答案 0 :(得分:-1)
在页面上选择一个元素,然后使用ExpectedConditions.stalenessOf(e)
等待它过时。
例如,
WebElement html = driver.findElement(By.tagName("html"));
new WebDriverWait(driver, 20).until(ExpectedConditions.stalenessOf(html));
// if you get here the page refreshed
如果您需要知道页面刷新的速度,您将需要添加一个秒表并在其之前启动并在此之后检查时间。如果要反复检查,则需要将上面的代码放在循环中,等等。