2010-08-18 33 views
0

我使用webdriver api(Selenium),当我试图测试一个站点(我可以在浏览器中正常浏览和浏览)时,我一遍又一遍地收到以下消息。webdriver一直抛出IOException并重新连接

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 

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

+0

请添加更多信息:源测试代码,Selenium版本,其中测试是从哪里运行? – 2010-08-18 09:18:06

回答

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); 
+0

嗨,我不明白为什么我需要代理,因为我试图在我的应用程序上运行测试,并且我的计算机IP不是被阻止的d。 – KJW 2010-08-18 18:43:55

+0

那么请给我们更多的信息。请参阅顶部的评论。 – 2010-08-19 06:09:03

+0

我现在明白了。我意识到应用程序正在加载滞后的广告。我是否必须为每个实例指定一个firefox配置文件?如果我想运行多个Firefox实例,我可以使用相同的配置文件吗? – KJW 2010-08-19 21:30:02

相关问题