最近,我升级到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 / 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 系统环境: Firefox 56.0.2 Java 1.8 seleniumjava-3.7.1 selenium服务器独立3.7.1 壁虎驱动程序-v0.19.1 错误跟踪日志: 用法: / usr / local / bin / geckodriver [选项] / usr / local / bin / geckodriver:未知选项–port = 8970线程“主”中的异常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’驱动程序信息:驱动程序.version:FirefoxDriver
包含的图书馆:
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
系统环境:
Firefox 56.0.2
Java 1.8
seleniumjava-3.7.1
selenium服务器独立3.7.1
壁虎驱动程序-v0.19.1
错误跟踪日志:
用法:
/ usr / local / bin / geckodriver [选项] / usr / local / bin / geckodriver:未知选项–port = 8970线程“主”中的异常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’驱动程序信息:驱动程序.version:FirefoxDriver
任何想法将不胜感激。谢谢。
尝试Debanjan建议后进行更新:
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 seleniumjava-3.7.1 selenium服务器独立3.7.1 壁虎起子0.19.1 Mac OS X”,os.arch:“ x86_64”,os.version:“ 10.12.6”
壁虎起子0.19.1
Mac OS X”,os.arch:“ x86_64”,os.version:“ 10.12.6”
调试1调试2在端口2198上启动ChromeDriver 2.33.506106(8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2)仅允许本地连接。线程“主”中的异常org.openqa.selenium.WebDriverException:等待驱动程序服务器启动时超时。内部版本信息:版本:‘3.7.1’,版本:‘8a0099a’,时间:‘2017-11-06T21:07:36.161Z’系统信息:主机:’Maggies- MacBook-Pro-2.local’,ip: ‘192.168.1.6’,操作系统名称:’Mac OS X’,os.arch:’x86_64’,os.version:‘10 .12.6’,java.version:‘1.8.0_121’驱动程序信息:driver.version:位于org.openqa.selenium的org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178)的org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:192)的ChromeDriver。[http:// localhost:2198 / status]](http://localhost:2198/status])将在20005毫秒后在org.openqa.selenium.remote.service.DriverService.waitUntilAvailable()的org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)处可用DriverService.java:187)…还有9个原因由:com.google.common.util.concurrent.SimpleTimeLimiter处java.util.concurrent.FutureTask.get(FutureTask.java:205)处的java.util.concurrent.TimeoutException org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)的.callWithTimeout(SimpleTimeLimiter.java:147)…还有10个
WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8970 由于不同的原因,可能会发生该错误。此外,您的Included Library列表中存在差异,这 selenium-server-standalone-3.7.1.jar 是从来没有下载的一部分 selenium- java-3.7.1.zip 。
WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8970
Included Library
selenium- java-3.7.1.zip
尝试以下提到的步骤:
jars
Download
Add
this link
确保 /etc/hosts 您的系统上包含以下条目:
/etc/hosts
1 127.0.0.1 localhost.localdomain localhost
运行CCleaner工具清除OS系统上的所有杂项。
CCleaner
OS
您可以选择System Reboot。
System Reboot
Test