执行我的selenium脚本时出现以下错误

时间:2016-10-25 05:33:41

标签: java selenium

异常的堆栈跟踪

1477308809616   geckodriver INFO    Listening on 127.0.0.1:11372
Oct 24, 2016 5:03:30 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
1477308810262   mozprofile::profile INFO    Using profile path C:\Users\PC-4\AppData\Local\Temp\rust_mozprofile.ppHCF7hshpOY
1477308810264   geckodriver::marionette INFO    Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe
1477308810268   geckodriver::marionette INFO    Connecting to Marionette on localhost:55966
1477308811347   Marionette  INFO    Listening on port 55966
1477308813944   Marionette  INFO    startBrowser 09e1e5f6-dc4a-4dcb-a2ad-783499097077
Oct 24, 2016 5:03:34 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[Child 7676] ###!!! ABORT: Aborting on channel error.: file c:/builds/moz2_slave/m-rel-w32-00000000000000000000/build/src/ipc/glue/MessageChannel.cpp, line 2052
Exception in thread "main" org.openqa.selenium.WebDriverException: Failed to decode response from marionette
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'Sheetal', ip: '192.168.1.16', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_40'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[], prefs={}}, appBuildId=20161019084923, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=7960, browserVersion=49.0.2, platformVersion=6.3, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt, device=desktop}]
Session ID: 09e1e5f6-dc4a-4dcb-a2ad-783499097077
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
    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.get(RemoteWebDriver.java:322)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteNavigation.to(RemoteWebDriver.java:902)
    at webdriverdemo.main(webdriverdemo.java:18)

1 个答案:

答案 0 :(得分:0)

试试这段代码: -

  String currentDir = System.getProperty("user.dir");
  String marionetteDriverLocation = currentDir +"/tools/marionette/wires.exe";
 System.setProperty("webdriver.gecko.driver", marionetteDriverLocation);
  WebDriver driver = new MarionetteDriver();

将geckodriver的名称更改为wires.exe