2

这是我在 Java 中的全部测试类,减去导入。

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();
    }
}

据我了解,implicitlyWait 命令应该在 5 秒后使用“ElementNotFound”使测试错误消失。这不会发生。它确实打开了一个 FF 窗口,进入谷歌,然后永远坐在那里。如果我关闭浏览器窗口,它将引发 UnreachableBrowser 异常(正如我所料)。我尝试过使用不同的时间单位,但没有任何区别。我正在使用硒 2.25。

4

1 回答 1

2

这似乎是 Selenium2.25和 Selenium的错误2.26,因此请尝试更新为2.27

于 2013-01-17T20:58:10.993 回答