Raj
Raj

Reputation: 31

How to disable flash plugin in Chrome and IE using Selenium/Java

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

Upvotes: 1

Views: 4222

Answers (2)

Fred Porci&#250;ncula
Fred Porci&#250;ncula

Reputation: 8902

I believe you have two options when working with Chrome. I don't know about IE, though. Your only option might be to manually configure it.

Disabling external plugins

Based on Disabling flash in Chrome. This will disable any external plugin, including Adobe Flash Player.

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

Disabling Adobe Flash Player plugin

Based on Disable flash in saucelabs/selenium webdriver?. This should disable only Adobe's plugin.

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

Upvotes: 0

Wolf
Wolf

Reputation: 922

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

Upvotes: 4

Related Questions