修改;
代码如下:
运行时,Firefox浏览器会启动如下;但是启动之后,就不会再操作浏览器
完整报错如下:
1612921550988 geckodriver INFO Listening on 127.0.0.1:20339
1612921551538 mozrunner::runner INFO Running command: “D:\Program Files (x86)\Mozilla Firefox\firefox.exe” “–marionette” “-foreground” “-no-remote” “-profile” “C:\Users\14165\AppData\Local\Temp\rust_mozprofileDHHiSK"
JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can’t find profile directory.
console.warn: SearchSettings: “get: No settings file exists, new profile?” (new Error(”", “(unknown module)”))
1612921557668 Marionette INFO Listening on port 62431
console.warn: SearchSettings: “get: No settings file exists, new profile?” (new Error("", “(unknown module)”))
1612921558010 Marionette ERROR [18] No reply from Marionette:Register
1612921558048 webdriver::command WARN You are using deprecated legacy session negotiation patterns (desiredCapabilities/requiredCapabilities), see https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities#Legacy
Exception in thread “main” org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@11c20519, version=, platform=ANY, firefox_profile=org.openqa.selenium.firefox.FirefoxProfile@70beb599}], required capabilities = Capabilities [{}]
Build info: version: ‘unknown’, revision: ‘86a5d70’, time: '2017-02-16 07:47:51 -0800’
System info: host: ‘LAPTOP-35Q8O8RF’, ip: ‘192.168.50.221’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: '1.8.0_181’
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:128)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:293)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:272)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:267)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:263)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:122)
at Test.main(Test.java:9)
Process finished with exit code 1
===================
应该还是Firefox和gecko版本不匹配,可是换了网上说的那些能够匹配上的版本(现在使用的gecko版本是0.24.0,Firefox是66),还是会有这个问题