如何使用Geckodriver保留我的Firefox配置文件缓存? [英] How can I retain my Firefox profile's cache with Geckodriver?

查看:543
本文介绍了如何使用Geckodriver保留我的Firefox配置文件缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Selenium和 Geckodriver 来保留我的缓存。我有一个Firefox配置文件,我在启动时加载 Geckodriver

I need to retain my cache with Selenium and Geckodriver. I have a Firefox profile and I load it upon startup of Geckodriver:

ProfilesIni profilesIni = new ProfilesIni();
FirefoxProfile firefoxProfile = profilesIni.getProfile("profile-name");
firefoxOptions.setProfile(firefoxProfile);

这是有效的,但复制缓存。转到 about:cache ,它是空的。我想保留我的缓存,我想直接使用我的个人资料。目前 Selenium / Geckodriver 复制部分配置文件并使用它,但不使用缓存。

This works as it is meant to, but it does not copy the cache. Going to about:cache, it's empty. I want to retain my cache, I want to use my profile directly. Currently Selenium/Geckodriver copies part of the profile and uses that, but not the cache.

我怎么能够使用 Geckodriver 时保持缓存?

How am I able to keep my cache when using Geckodriver?

推荐答案

找出解决方案。

使用此方法加载配置文件不起作用:

Loading the profile using this does not work:

FirefoxProfile firefoxProfile = profilesIni.getProfile("profile-name");

对我来说,这确实有效:

For me, this did however work:

String profilePath = "C\\Users\\Name\\AppData\\Local\\Mozilla\\Firefox\\Profiles\\myprofile";
FirefoxProfile firefoxProfile = new FirefoxProfile(new File(profilePath));

我现在拥有正确的完整缓存。

I now have my correct, full cache.

这篇关于如何使用Geckodriver保留我的Firefox配置文件缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆