java - webdriver 不断抛出 IOException 并重新连接

标签 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

为什么我总是收到此错误?

最佳答案

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

如果您使用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);

关于java - webdriver 不断抛出 IOException 并重新连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3510014/

相关文章:

c# - 如何从 div 标签中获取文本?

java - 使用 Selenium WebDriver 单击 Gmail 中的撰写按钮

java - HtmlUnit 代理问题

c# - 不知道为什么使用 headless (headless)浏览器

java - 将图像转换为二进制字符串

java - "Faceted Project Problem (Java Version Mismatch)"错误信息

java - 删除网址

java - 无法解决 ArithmeticException?/按零?

python - Selenium - 元素不可见 [Python]

python - Shell - 尝试输出日志文件的最后部分(时间戳是分隔符)