Marionette Driver Unreachable exception

戏子无情 提交于 2019-12-11 06:06:52

问题


I am using Firefox 47.0.1 with Marionette driver geckodriver-v0.8.0-win32. But I got unreachable browser exception and firefox not opening.

My code snippet looks like below :

System.setProperty("webdriver.gecko.driver", "C:/Documents and Settings/Admin/Desktop/wires-0.6.2-win/wires.exe");
GeckoDriverService service = new GeckoDriverService(new File("C:/Documents and Settings/Admin/Desktop/wires-0.6.2-win/wires.exe"), PortProber.findFreePort(), null, null);
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setCapability("marionette", true);
cap.setCapability("firefox_binary", "G:/Program Files/Mozilla Firefox/firefox.exe");
driver = new MarionetteDriver(service, cap,PortProber.findFreePort());

showing exception as :-

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: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40' System info: host: 'computer_1', ip: '192.168.1.100', os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0_79' Driver info: driver.version: MarionetteDriver


回答1:


There is no need for renaming geckodriver.exe to wires.exe. And usage of GeckoDriverService is not needed. With the stable release they've simplified the coding. Just download GeckoDriver and use it like

    System.setProperty("webdriver.gecko.driver", "path\\to\\geckodriver.exe");
    DesiredCapabilities caps = DesiredCapabilities.firefox();
    caps.setCapability(FirefoxDriver.BINARY, "G:\\Program Files\\Mozilla Firefox\\firefox.exe");
    WebDriver driver = new MarionetteDriver(caps);



回答2:


I'm assuming, you are using selenium 3.0 beta2. Here is the solution:

System.setProperty("webdriver.gecko.driver","C:\\geckodriver.exe"); //change geckodriver path accordingly.
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
webDriver = new MarionetteDriver(capabilities);

Please download latest geckodriver from https://github.com/mozilla/geckodriver/releases.



来源:https://stackoverflow.com/questions/37958497/marionette-driver-unreachable-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!