I am using selenium to automate website filling in chrome. When I download exe or XML files I am getting a popup 'This type of file can harm your computer' with keep and discard options. How to disable this programmatically ? I am implementing this in c#, I have tried,
chromeOptions.AddUserProfilePreference("disable-popup-blocking", "true")
But this is not working for me. How to disable this popup ? If not possible how to accept the warning ? Please help me.
To disable the message, you need to set the preference safebrowsing.enabled
to true
. Here is a working example with CSharp:
var options = new ChromeOptions();
options.AddUserProfilePreference("download.default_directory", "C:\\Downloads");
options.AddUserProfilePreference("download.prompt_for_download", false);
options.AddUserProfilePreference("download.directory_upgrade", true);
options.AddUserProfilePreference("safebrowsing.enabled", true);
var driver = new ChromeDriver(options);
driver.Navigate().GoToUrl("http://www.7-zip.org/a/7z1602.exe");
And for a description of the preferences:
https://chromium.googlesource.com/chromium/src/+/master/chrome/common/pref_names.cc