I'm using selenium chromedriver for automating web application. In my application, I need to download xml files. But when I download xml file, I get 'This type of file can harm your computer' pop up. I want to disable this pop up using selenium chromedriver and I want these type of files to be downloaded always. How can this be done?
UPDATE it's long standing Chrome bug from 2012.
Therefore, you should not see the generic "This type of file could harm your computer" warning message when you try to download a file type is supported by SmartScreen Application Reputation. This issue occurs because the file name extension in the URL differs from the actual file name extension.
In the three-dots menu, click “Settings.” On the “Settings” page, in the left sidebar, click “Security and Privacy.” In the “Security and Privacy” section on the right, click “Security” to access Chrome's security settings. On the “Security” page, in the “Safe Browsing” section, select the “No Protection” option.
The problem with XML files started to happen to me as of Chrome 47.0.2526.80 m. After spending maybe 6 hours trying to turn off every possible security option I tried a different approach.
Ironically, it seems that turning on the Chrome option "Protect you and your device from dangerous sites"
removes the message "This type of file can harm your computer. Do you want to keep file.xml anyway?"
I am using 'Ruby' with 'Watir-Webdriver' where the code looks like this:
prefs = { 'safebrowsing' => { 'enabled' => true, } } b = Watir::Browser.new :chrome, :prefs => prefs
Starting the browser like this, with safebrowsing
option enabled, downloads the xml files without the message warning. The principle should be the same for Selenium with any programming language.
##### Edited: 13-04-2017
In latest version of Google Chrome the above solution is not enough. Additionally, it is necessary to start the browser with the following switch:
--safebrowsing-disable-download-protection
Now, the code for starting the browser would look something like this:
b = Watir::Browser.new :chrome, :prefs => prefs, :switches => %w[--safebrowsing-disable-download-protection]))
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