硒WebDriver设置隐式等待什么都不做 [英] Selenium WebDriver setting ImplicitlyWait does nothing
本文介绍了硒WebDriver设置隐式等待什么都不做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class GoogleTest {
私有WebDriver驱动程序;
@Before
public void setUp(){
driver = new FirefoxDriver();
driver.manage()。timeouts()。implicitlyWait(5,TimeUnit.SECONDS);
@Test
public void testGoogleTest()抛出Exception {
driver.get(http://www.google.com);
driver.findElement(By.id(我不存在));
public void tearDown()抛出异常{
driver.quit();
$ b根据我的理解,implicitlyWait命令应该进行测试5秒后出现ElementNotFound错误。这不会发生。它确实打开一个FF窗口,去谷歌,然后永远坐在那里。如果我关闭浏览器窗口,它会抛出一个UnreachableBrowser异常(如我所料)。
我试过玩不同的时间单位,但没有什么区别。
我使用的是Selenium 2.25。
解决方案 这似乎是Selenium 2.25
和Selenium 2.26
,所以尝试更新到 2.27
Here is the entirety of my test class in Java, minus imports.
public class GoogleTest {
private WebDriver driver;
@Before
public void setUp() {
driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}
@Test
public void testGoogleTest() throws Exception {
driver.get("http://www.google.com");
driver.findElement(By.id("I don't exist"));
}
@After
public void tearDown() throws Exception {
driver.quit();
}
}
From my understanding, the implicitlyWait command should make the test error out with "ElementNotFound" after 5 seconds. This doesn't happen. It does open an FF window, goes to google and then sits there forever. If I close the browser window, it will throw an UnreachableBrowser exception (as I would expect).
I've tried playing around with different time units, but it made no difference.
I'm using Selenium 2.25.
解决方案 It seems to be a bug with Selenium 2.25
and Selenium 2.26
, so try updating to 2.27
这篇关于硒WebDriver设置隐式等待什么都不做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文