首页 > 解决方案 > Firefox 66.0 和 Geckodriver 0.24.0 不兼容?

问题描述

无法启动 Firefox。

尝试使用 Firefox 66.0 和 Geckodriver geckodriver 0.24.0

使用 Firefox 61.0 和 Geckodriver geckodriver 0.21.0

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("webdriver.log.driver", "INFO");
profile.setPreference("webdriver.log.file", targetDir + File.separator + "firefoxSeleniumServer.log");
profile.setPreference("browser.download.folderList",2);
profile.setPreference("browser.download.manager.showWhenStarting",false);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv;text/plain");
if(platform.equalsIgnoreCase("linux")) {
FirefoxOptions options = new FirefoxOptions();

profile.setPreference("browser.download.dir",System.getProperty("user.dir")+ File.separator + "target");
System.setProperty("webdriver.gecko.driver", "/geckodriver/geckodriver");
System.setProperty("webdriver.firefox.bin","/usr/bin/firefox/firefox");

options.setCapability(CapabilityType.PLATFORM_NAME,Platform.LINUX);
options.setCapability("marionette", true);
options.setCapability("webdriver.firefox.profile",DesiredCapabilities.firefox());
driver = new FirefoxDriver();
}

会话 ID:8d18af2e-b532-4991-af81-d446fb07bb6c 在 sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)

原因:java.lang.RuntimeException:fork 进程 org.openqa.selenium.NoSuchSessionException 中出现错误

标签: selenium-webdrivergeckodriverselenium-firefoxdriver

解决方案


根据此页面的“ https://github.com/mozilla/geckodriver/releases”“v0.24.0 ”也将支持 65+ 版本。要克服这些版本问题,您可以尝试“ https://github.com/bonigarcia/webdrivermanager ”,我们不需要为每个浏览器添加/替换 exe 文件。


推荐阅读