0
我想设置一个新的Selenium项目,并且无法使思想工作正确。我的环境:Selenium启动新的浏览器窗口,然后抛出UnreachableBrowserException
OSX : 10.12.4
Java : 1.8.0_121
Selenium : 3.4.0
Gecko : 0.16.1 (located at /opt/garbage/geckodriver and on path)
Firefox : 53.0.3
的Java代码
System.setProperty("webdriver.gecko.driver", "/opt/garbage/geckodriver");
System.setProperty("webdriver.firefox.marionette", "/opt/garbage/geckodriver");
WebDriver driver = new FirefoxDriver(); <--
driver.get("https://www.google.com");
在这个例子中,4号线将打开一个新的Firefox浏览器窗口中,但几秒钟后抛出下面的堆栈:
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'myhostname.corp', ip: '10.99.99.99', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.4', java.version: '1.8.0_121'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:658)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:191)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:108)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:104)
at com.example.TestClass.testMethod(TestClass.java:19)
而且来自失败运行的StdErr:
2017-06-05 12:24:08.483 firefox-bin[35514:5688975] IMKInputSession presentFunctionRowItemTextInputViewWithEndpoint:completionHandler: : [self textInputContext]=0x12cd37a00 *NO* NSRemoteViewController to client, NSError=Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 0" UserInfo={NSDebugDescription=connection from pid 0}, com.apple.inputmethod.EmojiFunctionRowItem
2017-06-05 12:24:08.891 firefox-bin[35514:5688975] IMKInputSession presentFunctionRowItemTextInputViewWithEndpoint:completionHandler: : [self textInputContext]=0x12cd37a00 *NO* NSRemoteViewController to client, NSError=Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 0" UserInfo={NSDebugDescription=connection from pid 0}, com.apple.inputmethod.EmojiFunctionRowItem
2017-06-05 12:24:09.248 plugin-container[35516:5689303] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x983b, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2017-06-05 12:24:09.248 plugin-container[35516:5689303] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x9b03, name = 'com.apple.CFPasteboardClient'
See /usr/include/servers/bootstrap_defs.h for the error codes.
我可能会错误配置什么?
编辑
我已经使用了以下功能也试过 - 没有变化
DesiredCapabilities caps = new FirefoxOptions()//
.setProfile(new FirefoxProfile())//
.addTo(DesiredCapabilities.firefox());
WebDriver driver = new FirefoxDriver(caps); <--
更新浏览器的驱动程序最新版本。像Cromer Cromedriver/IEdriver –
'0.16.1'好像是最新的驱动程序。 [源(https://github.com/mozilla/geckodriver/releases)。 –
此问题跟踪器可能会有所帮助:https://github.com/mozilla/geckodriver/issues –