user3160829 user3160829 - 1 year ago 74
C# Question

Chromedriver: How to disable PDF plugin

To mimic functionality of how my Firefox profile is set up, I need to ensure that the PDF viewer for Chrome is disabled. after searching across the internet, the closest answer I find is here

https://code.google.com/p/chromium/issues/detail?id=528436

However attempting any of the suggestions on this page have given me no success

Here is a snippet of code I expect to work

Dictionary<String, Object> plugin = new Dictionary<String, Object>();
plugin.Add("enabled", false );
plugin.Add("name", "Chrome PDF Viewer");
var options = new ChromeOptions();
options.AddUserProfilePreference("plugins.plugins_list", plugin);

driver = new ChromeDriver(options);


Can anyone see what exactly I am doing wrong? this is starting to become a really frustrating issue!

Answer Source

I found that this works for Selenium.WebDriver 2.53m, ChromeDriver 2.25.426923, and Chrome v55.0.2883.87 m.

    var options = new ChromeOptions();
    options.AddUserProfilePreference("plugins.plugins_disabled", new []{"Chrome PDF Viewer"});
    driver = new ChromeDriver(options);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download