0

我正在使用 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

为什么我不断收到此错误?

4

1 回答 1

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);
于 2010-08-18T09:16:31.800 回答