Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Selenium 3.7:geckodriver:WebDriverException:org.apache.http.conn.HttpHostConnectException连接被拒绝_Java_Selenium_Selenium Webdriver_Mozilla_Geckodriver - Fatal编程技术网

Java Selenium 3.7:geckodriver:WebDriverException:org.apache.http.conn.HttpHostConnectException连接被拒绝

Java Selenium 3.7:geckodriver:WebDriverException:org.apache.http.conn.HttpHostConnectException连接被拒绝,java,selenium,selenium-webdriver,mozilla,geckodriver,Java,Selenium,Selenium Webdriver,Mozilla,Geckodriver,最近我升级到Selenium 3.7 代码: 包含的库: 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");

最近我升级到Selenium 3.7

代码:

包含的库:

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-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/httpclient-4.5.3.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/commons-logging-1.2.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/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-sources.jar

系统环境:

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();
  }
Firefox 56.0.2

Java 1.8

selenium-java-3.7.1

selenium-server-standalone-3.7.1

壁虎河-v0.19.1

错误跟踪日志:

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();
  }
用法:

/usr/local/bin/geckodriver[选项]/usr/local/bin/geckodriver: 未知选项--线程“main”中的端口=8970异常 org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException:连接到 localhost:8970[localhost/0:0:0:0:0:0:1, localhost/fe80: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

任何想法都将不胜感激。多谢各位

试用德班健后更新建议:

代码:

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

系统环境:

Firefox 56.0.2

Java 1.8

selenium-java-3.7.1

selenium-server-standalone-3.7.1

壁虎河0.19.1

Mac OS X',OS.arch:'x86_64',OS.version:'10.12.6'

错误跟踪日志:

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();
  }
调试1调试2启动ChromeDriver 2.33.506106 (8A06C39C4582BFBAB6966DBB1C38A9173BFB1A2)仅在端口2198上本地 允许连接。线程“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.waitUntilavable(DriverService.java:192) 在 org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178) 在 org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79) 在 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600) 在 org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219) 在 org.openqa.selenium.remote.RemoteWebDriver(RemoteWebDriver.java:142) 在 org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:181) 在 org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:168) 在 org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123) 位于AutomationFrameWork.FirstTestCase.main(FirstTestCase.java:13) 原因:org.openqa.selenium.net.UrlChecker$TimeoutException:Timed 外出等待[以后有空] 20005毫秒 org.openqa.selenium.net.UrlChecker.waitUntilavable(UrlChecker.java:100) 在 org.openqa.selenium.remote.service.DriverService.waitUntilavable(DriverService.java:187) …9个以上原因:java.util.concurrent.TimeoutException java.util.concurrent.FutureTask.get(FutureTask.java:205)位于 com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:147) 在 org.openqa.selenium.net.UrlChecker.waitUntilavable(UrlChecker.java:75) …还有10个


我尝试了相同的版本,没有任何问题

如果通往壁虎河的路径:

System.setProperty("webdriver.gecko.driver", 
    "/usr/local/bin/geckodriver"); 
如果正确,请确保执行代码的用户可以执行geckodriver:

chmod +x geckodriver

我尝试了相同的版本,没有任何问题

如果通往壁虎河的路径:

System.setProperty("webdriver.gecko.driver", 
    "/usr/local/bin/geckodriver"); 
如果正确,请确保执行代码的用户可以执行geckodriver:

chmod +x geckodriver

我认为您缺少.exe扩展名。您的路径应该是这样的

System.setProperty("webdriver.gecko.driver", 
    "/usr/local/bin/geckodriver.exe");

我认为您缺少.exe扩展名。您的路径应该是这样的

System.setProperty("webdriver.gecko.driver", 
    "/usr/local/bin/geckodriver.exe");

错误WebDriverException:org.apache.http.conn.HttpHostConnectException:Connect to localhost:8970可能由于不同的原因而发生。 更多信息,在您的
收录库
列表中有一个差异,即
selenium-server-standalone-3.7.1.jar
绝不是下载的
selenium-java-3.7.1.zip的一部分

请尝试以下提到的步骤:

  • Included Library
    列表中删除所有
    jar
  • 从或从下载
    添加
    selenium-server-standalone-3.7.1.jar
  • 确保系统上的
    /etc/hosts
    包含以下条目:

    1 127.0.0.1               localhost.localdomain localhost
    
  • 运行
    CCleaner
    工具清除系统中的所有
    OS
    杂务

  • 您可以选择
    系统重新启动
  • 执行
    测试

    • 错误
      WebDriverException:org.apache.http.conn.HttpHostConnectException:连接到本地主机: