selenium-webdriver - 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 中出现错误
解决方案
根据此页面的“ https://github.com/mozilla/geckodriver/releases”“v0.24.0 ”也将支持 65+ 版本。要克服这些版本问题,您可以尝试“ https://github.com/bonigarcia/webdrivermanager ”,我们不需要为每个浏览器添加/替换 exe 文件。
推荐阅读
- java - 特殊字符不会被删除
- list - 如何将字符串列表转换为元组列表?(哈斯克尔)
- php - 对 foreach 结果进行排序
- python - 如何在 python 2.7 中将元素树中的元素写入 unicode 字符串
- python - 如何在 for 循环中调用我的函数并用它更新字典?
- javascript - 如何将 li 项中的值设置到搜索字段框中?
- javafx - 问题在层次结构中选择节点
- tensorflow - Keras CNN 如何减少大图像尺寸的 gpu 内存使用量?
- firebase - 在 firebase 函数中创建 FormData()
- c++ - 期待一个;, 或者 )?