Chromedriver, Selenium – Automate downloads

I had to dig into the source code on this one – I couldn’t find any docs listing the full set of Chrome User Preferences.

The key is "plugins.plugins_disabled": ["Chrome PDF Viewer"]}

FULL CODE:

dc = DesiredCapabilities.CHROME
dc['loggingPrefs'] = {'browser': 'ALL'}

chrome_profile = webdriver.ChromeOptions()
profile = {"download.default_directory": "C:\\SeleniumTests\\PDF",
           "download.prompt_for_download": False,
           "download.directory_upgrade": True,
           "plugins.plugins_disabled": ["Chrome PDF Viewer"]}
chrome_profile.add_experimental_option("prefs", profile)

#Helpful command line switches
# http://peter.sh/experiments/chromium-command-line-switches/
chrome_profile.add_argument("--disable-extensions")

self.driver = webdriver.Chrome(executable_path="C:\\SeleniumTests\\chromedriver.exe",
                               chrome_options=chrome_profile,
                               service_args=["--log-path=C:\\SeleniumTests\\chromedriver.log"],
                               desired_capabilities=dc)

Interestingly the blanket command chrome_profile.add_argument("--disable-plugins") switch did not solve this problem. But I prefer the more surgical approach anyways.

Leave a Comment