如何使用Selenium / Java在Chrome和IE中禁用Flash插件 [英] How to disable flash plugin in Chrome and IE using Selenium/Java

查看:626
本文介绍了如何使用Selenium / Java在Chrome和IE中禁用Flash插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Chrome使用了以下代码...但Chrome没有禁用Flash ..
即使我需要IE的代码

Used the following code for Chrome...But the flash is not disabled for Chrome.. Even I require the code for IE as well

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);


推荐答案

这就是我为Chrome工作的方式:

This is how i got it to work for Chrome:

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

这篇关于如何使用Selenium / Java在Chrome和IE中禁用Flash插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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