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
.chrome();
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);
capabilities.setCapability("chrome.binary",
chromeDriver.getAbsolutePath());
capabilities.setCapability(ChromeOptions.CAPABILITY,
options);
options.addArguments("--lang=en-gb");
GlobalVars.driver = new ChromeDriver(capabilities);
Updated for Chrome V: 57
This solution is no longer working.
Here is a valid implementation in C#:
var options = new ChromeOptions();
// This was a PAIN. If this ever does not work, here is how I got the preference name:
// 1. Navigate to : chrome://settings/content
// 2. Scroll to the bottom "PDF Documents" section
// 3. Right-Click and inspect element on the check box titled "Open PDF files in the default PDF viewer application"
// 4. The preference name is the pref key for the input, in this case: pref="plugins.always_open_pdf_externally"
options.AddUserProfilePreference("plugins.always_open_pdf_externally", true);
// The constructor must be pointed to the chrome driver .exe
// Or you must set a PATH variable pointing to the location
using (var driver = new ChromeDriver(options))
{
..........
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With