I am trying to automate downloading files using selenium with chrome as my browser using chromedriver. When i try downloading exe files its prompting me "This type of file can harm your computer, Discard or save it". i want it to download anyway without any prompt.
I have looked into few solutions like below:
chromeOptions = webdriver.ChromeOptions()
prefs = {"browser.helperApps.alwaysAsk.force" :False,"browser.helperApps.neverAsk.saveToDisk" : "application/octet-stream"}
chromeOptions.add_experimental_option("prefs",prefs)
browser = webdriver.Chrome(executable_path=//path//to//chrome_driver, chrome_options=chromeOptions)
But this didn't help it still throws up the prompt.
Any help on this is greatly appreciated.
Thanks,
解决方案
From what I understand, there is no way to tell Chrome not to warn on potentially dangerous binary file downloads, see:
As the simplest workaround, you might want to approach the problem with Firefox:
Also there have been numerous requests from dev community to allow to
disable this warning to be able to run automated tests in Chrome. At
the moment this is the only reason we're running our automated tests
in Firefox only. Really annoying.