Sai Kiran Sai Kiran - 2 years ago 1078
Java Question

How to disable Chrome Plugins in Selenium WebDriver using Java

Chrome Plugin pop up

When I am executing my Automation Code for this application the above popup is displayed. Now I would need to know how to disable PDF Viewer Plugin in Selenium WebDriver using Java.

Here's what I am using right now which is not working.

DesiredCapabilities capabilities = DesiredCapabilities
ChromeOptions options = new ChromeOptions();
options.addArguments(new String[] { "test-type" });
options.addArguments(new String[] { "disable-extensions" });

String pluginToDisable = "Chrome PDF Viewer";
options.addArguments("plugins.plugins_disabled", pluginToDisable);

GlobalVars.driver = new ChromeDriver(capabilities);

Answer Source

Here is an example to disable flash and the PDF viewer with Selenium/Chrome :

ChromeOptions options = new ChromeOptions();
Map<String, Object> preferences = new Hashtable<String, Object>();
options.setExperimentalOption("prefs", preferences);

// disable flash and the PDF viewer
preferences.put("plugins.plugins_disabled", new String[] {
    "Adobe Flash Player",
    "Chrome PDF Viewer"

// launch the browser and navigate to the page
ChromeDriver driver = new ChromeDriver(options);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download