问题描述
谁能告诉我如何使用 Java 为我的客户 Firefox 配置文件禁用插件?我发现一些网站显示添加附加组件,但没有关于禁用插件的内容.
Can someone tell me how to disable plugins for my customer firefox profile using Java? I have found a few sites showing to add add-ons but nothing about disable plugins.
我的 Firefox 个人资料:
My firefox profile:
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);
问题是默认情况下启用了一些插件.Adobe acrobat、google update、java、microsoft office、flash、shockwave for Director 和 silverlight.
The problem is by default this has some plugins enabled. Adobe acrobat, google update, java, microsoft office, flash, shockwave for director and silverlight.
我需要禁用其中的一些,因为它们会扰乱我的测试.
I need to disable some of these as they are messing up my tests.
推荐答案
除非您正在创建一个明确安装 firefox 扩展/插件的配置文件,否则 Selenium Webdriver 将创建一个空白配置文件并使用它.
Unless you are creating a profile that explicitly installs firefox extensions/plugins Selenium Webdriver will create a blank profile and use that.
您能告诉我们您使用什么代码来调用 FF 驱动程序吗?
Can you show us what code you are using to call the FF driver?
这篇关于Selenium 在 Firefox 配置文件中禁用插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!