Selenium 3.7:geckodriver:WebDriverException:org.apache.http.conn.HttpHostConnectException连接被拒绝 [英] Selenium 3.7 : geckodriver : WebDriverException: org.apache.http.conn.HttpHostConnectException Connection Refused
问题描述
最近我升级到了Selenium 3.7。
Recently I upgraded to Selenium 3.7.
代码:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public static void main (String args[]){
System.setProperty("webdriver.gecko.driver",
"/usr/local/bin/geckodriver");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
driver.quit();
}
包含的库:
selenium-java-3.7.1 / selenium-server-standalone-3.7.1.jar
selenium-java-3.7.1/selenium-server-standalone-3.7.1.jar
selenium-java-3.7.1 / libs / httpcore-4.4.6.jar
selenium-java-3.7.1/libs/httpcore-4.4.6.jar
selenium-java-3.7.1 / libs / httpclient-4.5.3.jar
selenium-java-3.7.1/libs/httpclient-4.5.3.jar
selenium-java-3.7.1 / libs / guava-23.0.jar
selenium-java-3.7.1/libs/guava-23.0.jar
selenium-java-3.7。 1 / libs / gson-2.8.2.jar
selenium-java-3.7.1/libs/gson-2.8.2.jar
selenium-java-3.7.1 / libs / commons-logging-1.2.jar
selenium-java-3.7.1/libs/commons-logging-1.2.jar
selenium-java-3.7.1 / libs / commons-exec-1.3.jar
selenium-java-3.7.1/libs/commons-exec-1.3.jar
selenium-java-3.7.1 / libs / commons-codec-1.10.jar
selenium-java-3.7.1/libs/commons-codec-1.10.jar
selenium-java-3.7.1 / libs / byte-buddy-1.7.5.jar
selenium-java-3.7.1/libs/byte-buddy-1.7.5.jar
selenium-java-3.7.1 / client-combined-3.7.1.jar
selenium-java-3.7.1/client-combined-3.7.1.jar
selenium-java-3.7.1 / client-combined- 3.7.1-sources.jar
selenium-java-3.7.1/client-combined-3.7.1-sources.jar
系统环境:
Firefox 56.0。 2
Firefox 56.0.2
Java 1.8
selenium-java-3.7.1
selenium-java-3.7.1
selenium-server-standalone-3.7.1
selenium-server-standalone-3.7.1
geckodriver - v0.19.1
geckodriver - v0.19.1
错误跟踪日志:
用法:
/ usr / local / bin / geckodriver [OPTIONS] / usr / local / bin / geckodriver:
未知选项--port = 8970线程main中的异常
org.openqa.selenium.WebDriverException:
org.apache.http.conn.HttpHostConnectException:连接到
localhost:8970 [localhost / 0:0:0:0:0:0:0 :1,
localhost / fe80:0:0:0:0:0:0:1%1]失败:连接被拒绝(连接
拒绝)构建信息:版本:'3.7.1',修订版:'8a0099a',时间:
'2017-11-06T21:07:36.161Z'系统信息:主机:
'Maggies-MacBook-Pro-2.local',ip:'192.168。 1.6',os.name:'Mac OS X',
os.arch:'x86_64',os.version:'10 .12.6',java.version:'1.8.0_121'
驱动程序信息:driver.version:FirefoxDriver
/usr/local/bin/geckodriver [OPTIONS] /usr/local/bin/geckodriver: Unknown option --port=8970 Exception in thread "main" org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8970 [localhost/0:0:0:0:0:0:0:1, localhost/fe80:0:0:0:0:0:0:1%1] failed: Connection refused (Connection refused) Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z' System info: host: 'Maggies-MacBook-Pro-2.local', ip: '192.168.1.6', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_121' Driver info: driver.version: FirefoxDriver
任何想法将不胜感激。谢谢。
Any idea would be appreciated. Thank you.
尝试Debanjan建议后更新:
Update after trying Debanjan suggestion:
代码:
public static void main (String args[]){
System.out.println("Debug 1");
System.setProperty("webdriver.gecko.driver",
"/Users/maggie/Documents/ToolsQA/Libs/geckodriver");
System.out.println("Debug 2");
WebDriver driver = new FirefoxDriver();
System.out.println("Debug 3");
driver.get("http://www.google.com");
driver.quit();
}
包含图书馆:
selenium-server-standalone-3.7.1.jar
selenium-server-standalone-3.7.1.jar
系统环境:
Firefox 56.0.2
Firefox 56.0.2
Java 1.8
selenium-java-3.7.1
selenium-java-3.7.1
selenium-server-standalone-3.7.1
selenium-server-standalone-3.7.1
geckodriver 0.19.1
geckodriver 0.19.1
Mac OS X',os.arch:'x86_64',os.version:'10 .12.6'
Mac OS X', os.arch: 'x86_64', os.version: '10.12.6'
错误跟踪日志:
调试1调试2在端口2198上启动ChromeDriver 2.33.506106
(8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2)仅允许本地
连接。线程main中的异常
org.openqa.selenium.WebDriverException:等待驱动程序
服务器启动超时。构建信息:版本:'3.7.1',修订版:'8a0099a',
时间:'2017-11-06T21:07:36.161Z'系统信息:主机:
'Maggies-MacBook-Pro -2.local',ip:'192.168.1.6',os.name:'Mac OS X',
os.arch:'x86_64',os.version:'10 .12.6',java.version: '1.8.0_121'
驱动程序信息:driver.version:ChromeDriver at
org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:192)
at
org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178)
at
org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
at
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver。 java:219)
at
org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:142)
at
org.openqa.selenium.chrome.C hromeDriver。(ChromeDriver.java:181)
at
org.openqa.selenium.chrome.ChromeDriver。(ChromeDriver.java:168)
at
org.openqa.selenium。 chrome.ChromeDriver。(ChromeDriver.java:123)
at AutomationFrameWork.FirstTestCase.main(FirstTestCase.java:13)
引起:org.openqa.selenium.net.UrlChecker $ TimeoutException:Timed $ b在$ b $之后等待[ http:// localhost:2198 / status] 的$ b b 20005 ms at
org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
at
org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService .java:187)
... 9更多引起:
的java.util.concurrent.TimeoutException java.util.concurrent.FutureTask.get(FutureTask.java:205)at
com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:147)
at
org.openqa.selenium.ne t.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
... 10 more
Debug 1 Debug 2 Starting ChromeDriver 2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2) on port 2198 Only local connections are allowed. Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start. Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z' System info: host: 'Maggies-MacBook-Pro-2.local', ip: '192.168.1.6', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_121' Driver info: driver.version: ChromeDriver at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:192) at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:142) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:181) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:168) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123) at AutomationFrameWork.FirstTestCase.main(FirstTestCase.java:13) Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:2198/status] to be available after 20005 ms at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100) at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:187) ... 9 more Caused by: java.util.concurrent.TimeoutException at java.util.concurrent.FutureTask.get(FutureTask.java:205) at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:147) at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75) ... 10 more
推荐答案
错误 WebDriverException:org.apache.http.conn.HttpHostConnectException:由于不同的原因,可能会发生连接到localhost:8970
。
更多关于您的包含的库
列表中存在差异 selenium-server-standalone-3.7.1.jar
绝不是下载 selenium-java-3.7.1.zip
的一部分。
The error WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8970
can occur due to different reasons.
More over there is a discrepency in your Included Library
list as selenium-server-standalone-3.7.1.jar
is never a part of downloaded selenium-java-3.7.1.zip
.
尝试以下步骤:
- 来自
包含的库
列表删除所有jars
。 -
下载
和添加
仅selenium-server-standalone-3.7.1.jar
来自此链接
或此链接
-
确保
/ etc / hosts
您的系统上的strong>包含以下条目:
- From the
Included Library
list remove all thejars
. Download
andAdd
onlyselenium-server-standalone-3.7.1.jar
fromthis link
or fromthis link
Ensure that
/etc/hosts
on your system contains the following entry :
1 127.0.0.1 localhost.localdomain localhost
运行 CCleaner
擦除所有 OS
系统中的杂项。
Run CCleaner
Tool to wipe away all the OS
chores from your system.
这篇关于Selenium 3.7:geckodriver:WebDriverException:org.apache.http.conn.HttpHostConnectException连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!