webdriver不断抛出IOException并重新连接

时间:2010-08-18 07:57:43

标签: java selenium webdriver

我正在使用webdriver api(Selenium),当我尝试测试一个站点(我可以在浏览器中正常查看和浏览)时,我反复收到以下消息。

INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
18-Aug-2010 12:36:08 AM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry

为什么我一直收到此错误?

1 个答案:

答案 0 :(得分:1)

看起来您必须配置代理。如果没有配置,我会得到同样的错误。

如果您使用HtmlUnitDriver(您必须使用WebDriver的具体实现来访问setProxy方法:

HtmlUnitDriver d = new HtmlUnitDriver();
d.setProxy("your.proxy.here", proxyPort);

如果您使用FirefoxDriver

FirefoxProfile firefoxProfile = new FirefoxProfile();
Proxy proxy = new Proxy();
proxy.setHttpProxy("your.proxy.here:proxyPort");
firefoxProfile.setProxyPreferences(proxy);
WebDriver driver = new FirefoxDriver(firefoxProfile);