如何使用Geckodriver保留我的Firefox配置文件缓存?
我需要使用Selenium和Geckodriver
保留我的缓存。 我有一个Firefox配置文件,我在启动Geckodriver
时加载它:
ProfilesIni profilesIni = new ProfilesIni(); FirefoxProfile firefoxProfile = profilesIni.getProfile("profile-name"); firefoxOptions.setProfile(firefoxProfile);
这可以正常工作,但它不会复制缓存。 去about:cache
,它是空的。 我想保留我的缓存,我想直接使用我的个人资料。 目前, Selenium/Geckodriver
复制部分配置文件并使用它,但不会使用缓存。
使用Geckodriver
时如何保持缓存?
我正在使用现有的自定义Firefox配置文件与此代码(完整):
FirefoxOptions options = new FirefoxOptions(); ProfilesIni allProfiles = new ProfilesIni(); FirefoxProfile selenium_profile = allProfiles.getProfile("selenium_profile"); options.setProfile(selenium_profile); options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); System.setProperty("webdriver.gecko.driver", "C:\\Users\\pburgr\\Desktop\\geckodriver-v0.20.0-win64\\geckodriver.exe"); driver = new FirefoxDriver(options); driver.manage().window().maximize();
我的缓存“正常”增长。
如果零缓存仍然存在,请检查Firefox配置文件的设置(关闭时删除缓存)。
找出解决方案。
使用此加载配置文件不起作用:
FirefoxProfile firefoxProfile = profilesIni.getProfile("profile-name");
对我来说,这确实有效:
String profilePath = "C\\Users\\Name\\AppData\\Local\\Mozilla\\Firefox\\Profiles\\myprofile"; FirefoxProfile firefoxProfile = new FirefoxProfile(new File(profilePath));
我现在拥有正确的完整缓存。
- 在Firefox中自动下载pdf文件
- Firefox错误:使用Java启动Selenium 3.0.1驱动程序时“您的连接不安全”
- Selenium 3.0 Firefx驱动程序因org.openqa.selenium.SessionNotCreatedException而失败:无法创建新的远程会话
- 像Firefox一样使用标题制作JPanel边框
- 如何使用Selenium webdriver和Java为firefox设置代理?
- 如何使用Geckodriver禁用Selenium中的Firefox日志记录?
- Java Web Start Applet打开新的浏览器窗口/选项卡忽略目标
- 启动Firefox并等待它关闭
- 如何使用FirefoxProfile通过Firefox浏览器自动下载?