0

我的测试类(java)中有以下代码,但超时似乎不起作用(它根本没有效果)。我已经用非常慢的连接对其进行了测试,我预计它会在 5 秒后失败,但它会无限期地等待页面加载,有时它会在 8-10 秒内返回,并且测试通过,因为页面实际加载但不在我指定的时间。知道为什么页面超时命令没有做它应该做的事情吗?

protected static WebDriver driver; driver = new FirefoxDriver(); driver.manage().timeouts().pageLoadTimeout(5,TimeUnit.SECONDS); driver.get("http://www.google.com");

我正在使用 Selenium 2.20.0。

提前致谢

4

2 回答 2

0

pageLoadTimeOut makes no sense without "unstable" Firefox profile.

Probably, you will have to either download the plugin been mentioned at the selenium download page OR write a while loop that would run indefinitely and break only when the element is found. Make use of try-catch blocks as well.

于 2012-07-26T18:58:31.263 回答
0

然后将其报告为问题

http://code.google.com/p/selenium/issues/list

于 2012-05-11T11:06:35.227 回答