【发布时间】:2014-08-18 10:19:47
【问题描述】:
我在尝试单击链接文本时遇到问题。问题是页面加载时间过长并导致异常:“命令持续时间或超时:60.01 秒”。我也设置了:
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(180, TimeUnit.SECONDS);
driver.manage().timeouts().setScriptTimeout(180, TimeUnit.SECONDS);
总是在 60.01 秒后超时,看起来代码无法覆盖页面加载的默认超时时间。我正在使用 chrome 驱动程序。这是我的代码:
driver.get(baseUrl + "?k=" + test.Key);
// verify the MoCoin icon exists
assertTrue("The 'MoCoin' icon does not exist",
driver.findElements(By.id("tokens-navbar")).size() != 0);
// verify the 'pronews' menu exists
assertTrue("The the 'pronews' menu does not exist", driver
.findElements(By.linkText("PRONEWS")).size() != 0);
// click on the 'pronews' menu
driver.findElement(By.linkText("PRONEWS")).click(); // exception here, the element was clicked and the new page was loading
有没有办法覆盖页面加载的时间?或者任何停止页面加载的技巧,以便我可以验证标题和其他元素?任何帮助都会很棒。
【问题讨论】:
-
我也有同样的问题。如果你找到了,我很想知道答案。
-
我不记得我为克服这个问题做了什么。我使用Appium 进行自动化测试,我只是将此应用程序的超时设置为 60 多秒。该问题不属于网络驱动程序。希望对你有帮助。