1

我正在使用Firefox 47.0.1驱动Marionette程序geckodriver-v0.8.0-win32。但是我得到了无法访问的浏览器异常并且firefox没有打开。

我的代码片段如下所示:

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());

显示exception为:-

org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败。构建信息:版本:'2.53.0',修订:'35ae25b',时间:'2016-03-15 16:57:40' 系统信息:主机:'computer_1',ip:'192.168.1.100',os。名称:'Windows XP',os.arch:'x86',os.version:'5.1',java.version:'1.7.0_79' 驱动程序信息:driver.version:MarionetteDriver

4

2 回答 2

0

我假设,您使用的是 selenium 3.0 beta2。这是解决方案:

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

请从https://github.com/mozilla/geckodriver/releases下载最新的 geckodriver 。

于 2016-08-26T18:12:32.013 回答
0

无需重命名geckodriver.exewires.exe. 并且不需要使用 GeckoDriverService。通过稳定版本,他们简化了编码。只需下载GeckoDriver并使用它

    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);
于 2016-06-24T04:36:01.920 回答