当我运行Firefox
司机,第一次它得到的是它的正常工作在每次运行后失败。
这可以通过以下方式发生:
org.openqa.selenium.WebDriverException: connection refused Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53' System info: host: 'SAURABH-PC', ip: '192.168.3.8', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_161' Driver info: driver.version: unknown remote stacktrace: Command duration or timeout: 66.09 seconds at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166) at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$errorHandler$0(JsonWireProtocolResponse.java:54) at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30) at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958) at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:252)
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:49153/wd/hub"), capabilities);
Selenium-standalone.jar
java -Dwebdriver.gecko.driver=<path-to-geckodriver>\geckodriver.exe -jar <path-to-selenium-server-standalone.jar>\selenium-server-standalone.jar -port 49153
Feb 06, 2019 6:29:24 PM org.openqa.selenium.remote.DesiredCapabilities firefox
INFO: Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
Feb 06, 2019 6:29:44 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
"value":{"error":"unknown error","message":"connection refused","stacktrace":""}}
1549457898669 mozrunner::runner INFO Running command: "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\Saurabh\\AppData\\Local\\Temp\\rust_mozprofile.2UOp20Lx725Q"
1549457899002 geckodriver::marionette DEBUG Waiting 60s to connect to browser on 127.0.0.1:51325
1549457915749 [email protected] WARN Loading extension '[email protected]': Reading manifest: Invalid host permission: resource://pdf.js/
1549457915749 [email protected] WARN Loading extension '[email protected]': Reading manifest: Invalid host permission: about:reader*
1549457916114 Marionette TRACE Received observer notification profile-after-change
1549457917888 Marionette TRACE Received observer notification toplevel-window-ready
1549457918713 Marionette TRACE Received observer notification command-line-startup
1549457918714 Marionette TRACE Received observer notification nsPref:changed
1549457918714 Marionette DEBUG Init aborted (running=false, enabled=true, finalUIStartup=false)
1549457925550 Marionette TRACE Received observer notification toplevel-window-ready
1549457948093 Marionette TRACE Received observer notification sessionstore-windows-restored
1549457948093 Marionette TRACE Waiting until startup recorder finished recording startup scripts...
1549457959572 mozrunner::runner DEBUG Killing process 11516
Exiting due to channel error.
Exiting due to channel error.
1549457960997 webdriver::server DEBUG <- 500 Internal Server Error {"value":{"error":"unknown error","message":"connection refused","stacktrace":""}}
1549457965775 mozrunner::runner INFO Running command: "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\Saurabh\\AppData\\Local\\Temp\\rust_mozprofile.0d9kqn5LP57h"
1549457965997 geckodriver::marionette DEBUG Waiting 60s to connect to browser on 127.0.0.1:51620
1549457995244 [email protected] WARN Loading extension '[email protected]': Reading manifest: Invalid host permission: resource://pdf.js/
1549457995245 [email protected] WARN Loading extension '[email protected]': Reading manifest: Invalid host permission: about:reader*
1549457995902 Marionette TRACE Received observer notification profile-after-change
1549457998402 Marionette TRACE Received observer notification toplevel-window-ready
1549457998814 Marionette TRACE Received observer notification command-line-startup
1549457998814 Marionette TRACE Received observer notification nsPref:changed
1549457998814 Marionette DEBUG Init aborted (running=false, enabled=true, finalUIStartup=false)
此错误消息...
org.openqa.selenium.WebDriverException: connection refused
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53' System info: host: 'SAURABH-PC', ip: '192.168.3.8', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_161' Driver info: driver.version: unknown
......意味着GeckoDriver无法启动/生成一个新的会话网页浏览火狐即浏览器会话。
你的主要问题是您正在使用如下的二进制文件的版本之间的不兼容性:
于是就有了JDK v8u161,硒客户v3.141.59,GeckoDriver v0.24.0和Firefox浏览器v65.0之间有明显的不匹配