Selenium禁用firefox配置文件中的插件

Doc*_*Who 6 java firefox selenium automation selenium-webdriver

有人能告诉我如何使用Java为我的客户firefox配置文件禁用插件吗?我发现一些网站显示添加附加组件,但没有关于禁用插件的信息.

我的firefox个人资料:

    FirefoxProfile firefoxProfile = new FirefoxProfile();
    firefoxProfile.setAcceptUntrustedCertificates(true);
    firefoxProfile.setAssumeUntrustedCertificateIssuer(false);
    firefoxProfile.setPreference("browser.download.folderList",2);
    firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false);
    firefoxProfile.setPreference("browser.download.dir",reportFolder);
    firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv,application/pdf,application/csv,application/vnd.ms-excel");
    firefoxProfile.setPreference("browser.download.manager.showAlertOnComplete",false);  firefoxProfile.setPreference("browser.download.manager.showAlertOnComplete",false);
    firefoxProfile.setPreference("browser.download.manager.showWhenStartinge",false);
    firefoxProfile.setPreference("browser.download.panel.shown",false);
    firefoxProfile.setPreference("browser.download.useToolkitUI",true);
    firefoxProfile.setPreference("pdfjs.disabled", true);
    firefoxProfile.setPreference("pdfjs.firstRun", false);
driver = new FirefoxDriver(firefoxProfile);
Run Code Online (Sandbox Code Playgroud)

问题是默认情况下启用了一些插件.Adobe acrobat,google update,java,microsoft office,flash,shockwave for director和silverlight.

我需要禁用其中一些,因为它们搞砸了我的测试.

Far*_*lan 2

除非您正在创建显式安装 Firefox 扩展/插件的配置文件,否则 Selenium Webdriver 将创建一个空白配置文件并使用它。

您能告诉我们您使用什么代码来调用 FF 驱动程序吗?

  • 尝试添加此首选项:“plugin.disable_full_page_plugin_for_types”,“application/pdf”` (3认同)
  • 根据您的 Firefox 版本,除了 application/pdf 之外,您可能还必须包含其他几种 MIME 类型: `firefoxProfile.setPreference("plugin.disable_full_page_plugin_for_types", "application/pdf,application/vnd.adobe.xfdf,application/vnd. fdf,application/vnd.adobe.xdp+xml");` (2认同)