Jim*_*ans 11
退出页面加载等待的最简单方法是设置页面加载超时.当超时到期时,您可以捕获TimeoutException并继续下一步测试.调用它的代码如下所示:
// Set the page load timeout to 10 seconds.
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
try {
driver.get("http://url/to/my/slow/loading/page");
} catch (TimeoutException e) {
// Ignore the exception.
}
// Proceed with your next step here.
Run Code Online (Sandbox Code Playgroud)
请注意,您可能必须使用WebDriverWait或类似,以确保页面上存在您感兴趣的元素.
| 归档时间: |
|
| 查看次数: |
8506 次 |
| 最近记录: |