问题
I've seen this issue around, but, unfortunately, I have struggled to find a definite resolution.
Perhaps, if someone has it working for themselves, they could share what firefox and geckodriver combination they have it working with.
Edit: I am running this through Jenkins, so maybe there is an embedded firefox in Jenkins that this is using, which differs from that on the server, itself.
For myself, I am using: Centos 7 Mozilla Firefox 67.0 GeckoDriver version 0.26.0 (for linux64; downloaded from here: https://github.com/mozilla/geckodriver/releases) org.seleniumhq.selenium:selenium-server:3.4.0
Below is the stacktrace that I get (in place of the package paths, I put the lines of my code in bold where this issue is triggered):
_org.openqa.selenium.WebDriverException: Failed to decode response from marionette Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: 'jenkins2', ip: '172.16.12.149', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-957.21.3.el7.x86_64', java.version: '1.8.0_211' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{moz:profile=/tmp/rust_mozprofileuGyLim, rotatable=false, moz:geckodriverVersion=0.26.0, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss and notify, strictFileInteractability=false, moz:headless=true, platform=ANY, moz:accessibilityChecks=false, moz:useNonSpecCompliantPointerOrigin=false, acceptInsecureCerts=false, browserVersion=67.0, moz:shutdownTimeout=60000.0, platformVersion=3.10.0-957.21.3.el7.x86_64, moz:processID=31137.0, browserName=firefox, moz:buildID=20190516215225, javascriptEnabled=true, platformName=linux, setWindowRect=true, moz:webdriverClick=true}] Session ID: bd33f758-d6fa-46a4-8e52-c9d019f8ec43 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.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:150) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:115) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:45) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637) at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:364) at "driver.get(url);"(LandingPage.java:385) at "accessFirefox();" (LandingPage.java:338) at "accessPage(browser);"(LandingPage.java:45) at "landingPage = new LandingPage();"BasicTest.java:14) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)_
回答1:
Here is the answer, so far:
Firefox versions after 64 apparently don't work (https://github.com/mozilla/geckodriver/issues/1560).
As part of my troubleshooting, I switched between several different versions of firefox, 70.0, 69.0.3, 67.0, 65.0.2 and 64.0.2. Of these versions, only 64.0.2 worked.
The geckodriver developers are aware of this issue, though it has been a while.
来源:https://stackoverflow.com/questions/58544316/selenium-failed-to-decode-response-from-marionette