【问题标题】:How to disable flash plugin in Chrome and IE using Selenium/Java如何使用 Selenium/Java 在 Chrome 和 IE 中禁用 flash 插件
【发布时间】:2015-08-07 14:34:00
【问题描述】:

为 Chrome 使用了以下代码...但是 Chrome 没有禁用 Flash .. 甚至我也需要 IE 的代码

ChromeOptions options = new ChromeOptions();
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_settings.state.flash",0);
//profile.default_content_settings.popups
options.setExperimentalOption("prefs", prefs);  
System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+"\\chromedriver.exe");
driver = new ChromeDriver(options);

【问题讨论】:

  • 您是要禁用 Adob​​e 的 flash 插件还是 Chrome 的捆绑 flash?
  • Adobe Flash Player..我还需要 IE 的代码..那会很有帮助
  • 您可以disable external plugins,从而禁用Adobe Flash Player,也可以disable specifically Adobe's plugin。不过,我不了解 IE。
  • 谢谢...你能提供 Chrome 的代码吗...

标签: java selenium-webdriver


【解决方案1】:

这就是我让它在 Chrome 上工作的方式:

ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-bundled-ppapi-flash");
WebDriver webDriver = new org.openqa.selenium.chrome.ChromeDriver(options);

【讨论】:

  • 这将禁用 Chrome 的捆绑 Flash,而不是 Adob​​e 的 Flash 插件。
  • 我真的不明白其中的区别。嵌入插件不是Adobe提供的吗? (请参阅:adobe.com/software/flash/about)但是,当我使用该参数时,about:plugins 部分中不再出现 Flash 插件,并且 Flash 不再适合我。
  • 嵌入式插件由 Adob​​e 提供,但您仍然可以在此基础上安装他们的常规插件。检查此链接上的第二个问题:helpx.adobe.com/flash-player/kb/flash-player-google-chrome.html
【解决方案2】:

我相信您在使用 Chrome 时有两种选择。不过,我不知道 IE。您唯一的选择可能是手动配置它。

禁用外部插件

基于Disabling flash in Chrome。这将禁用任何外部插件,包括 Adob​​e Flash Player。

ChromeOptions options = new ChromeOptions();
options.AddArguments("--disable-plugins-discovery");
WebDriver driver = new ChromeDriver(options);

禁用 Adob​​e Flash Player 插件

基于Disable flash in saucelabs/selenium webdriver?。这应该只禁用 Adob​​e 的插件。

Map<String, Object> prefs = new HashMap<>();
prefs.put("plugins.plugins_disabled", "Adobe Flash Player");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);  
WebDriver driver = new ChromeDriver(options);

【讨论】:

  • 我很确定以上是针对 java 的。如果您使用的是 C#,则将 setExperimentalOption 等内容重命名为 AddAdditionalCapability 等。
  • 它是 Java。这个问题毕竟有Java标签。
猜你喜欢
  • 1970-01-01
  • 2016-10-18
  • 2020-05-13
  • 2017-08-03
  • 2018-07-07
  • 2015-01-28
  • 2013-04-30
  • 1970-01-01
  • 2010-10-25
相关资源
最近更新 更多