1

I am writing a Selenium script in C# that goes through a page, clicking download buttons to download multiple .msg files. Every time it clicks a button to download a file, I receive a Chrome message saying the file may be harmful and asking if I want to keep or discard it. This is an issue because I need to download thousands of files, so I cannot press keep thousands of times. I have tried every solution imaginable from this question being asked previously, with no luck. I am using Selenium WebDriver v3.141.0, ChromeDriver v79.0.3945.3600, and Google Chrome Version 79.0.3945.130 (Official Build) (64-bit). This is the code I am using to set preferences, and I have verified that the preferences are being set successfully:

ChromeOptions options = new ChromeOptions();
string downloadDirectory = @"C:\Path\to\directory";

options.AddArgument("--start-maximized");
options.AddArgument("--safebrowsing-disable-download-protection");
options.AddArgument("--safebrowsing-disable-extension-blacklist");

options.AddUserProfilePreference("download.default_directory", downloadDirectory);
options.AddUserProfilePreference("download.prompt_for_download", "false");
options.AddUserProfilePreference("download.directory_upgrade", true);
options.AddUserProfilePreference("disable-popup-blocking", "true");           
options.AddUserProfilePreference("safebrowsing", "enabled");

IWebDriver driver = new ChromeDriver(options);

0 Answers0