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 –