【问题标题】:How to disable firstrun page in add-on - selenium - firefox - java如何禁用插件中的首次运行页面 - selenium - firefox - java
【发布时间】:2018-10-07 15:33:54
【问题描述】:
我正在通过 selenium webdriver 触发 firefox 浏览器。我在 selenium 中添加扩展/附加“隐私獾”。每当我触发浏览器时,我都会从该插件moz-extension://a1f88f6a-2513-490f-815f-f5d36dcae685/pages/welcome/welcome.html
获得第一次运行的 html 页面
有没有办法在 selenium 中禁用它?
通过 Firefox 配置文件添加扩展
final String privacyBadgerAddonPath = "src/com/test/jk/addon/privacy-badger-latest.xpi";
firefoxProfile.addExtension(new File(privacyBadgerAddonPath));
火狐版本:52
硒版本:3.14.0
我看到了这个solution,但不确定如何在这个插件中使用它。他们是如何想出“noscript.version”的
谢谢
呸
【问题讨论】:
标签:
selenium
selenium-webdriver
firefox-addon
【解决方案1】:
Selenium 默认使用临时浏览器配置文件。使用现有的浏览器配置文件,您几乎可以使用任何自定义,甚至是附加组件。我的设置是加载名为“selenium_profile”的现有配置文件:
@BeforeClass
public static void setUpClass() {
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 配置文件,请按 Win+R 并输入命令“firefox.exe -p”。其余的由您来管理。