Selenium WebDriver findelement卡住了Java? [英] Selenium WebDriver findelement stuck java?

查看:422
本文介绍了Selenium WebDriver findelement卡住了Java?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Selenium Webdriver编写一个非常简单的测试用例。可以说我有

I am writing a very simple test case using selenium webdriver. Lets say I have

@Test
public void github_search() {
    this.webDriver.get("http://www.github.com");

    WebElement findBox = this.webDriver.findElement(By.id("qa"));

......
}

测试中,页面上没有ID为 qa的元素,在这种情况下,我只不过使用findElement方法抛出异常。但事实并非如此。硒实际上似乎被卡住了。我唯一能做的就是手动关闭浏览器。我想知道如何处理这种情况,如果该元素不存在,那么它会等待一段时间,最后应该抛出一个异常。

in this test, there is no element on the page with id of "qa", in this case I am excepting the findElement method to throw an exception. But it doesn't. Selenium actually appears to be stuck. Only thing I could do is manually close the browser. I was wondering how to handle such situation where if the element doesn't exist then it waits for some time and, finally it should just throw an exception.

推荐答案

只需下载最新的2.27版本:

Just download latest 2.27 release:

https://code.google.com/p/selenium/downloads/list

这篇关于Selenium WebDriver findelement卡住了Java?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆