如何使用Selenium / Java在Chrome和IE中禁用Flash插件

如何使用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);