Chrome 85 - Download issue - This file may harm your computer prompt

408 views
Skip to first unread message

Ashwin Balaji Kuppuraj

unread,
Mar 12, 2021, 4:05:36 AM3/12/21
to ChromeDriver Users
Even after setting all the below option in the Custom Chrome driver, I am getting the prompt when downloading the "xml file"

    chromePrefs.put("profile.default_content_settings.popups", 0);// NOI18N
    chromePrefs.put("download.default_directory", downloadDir);// NOI18N
chromePrefs.put("download.prompt_for_download", "false");// NOI18N
chromePrefs.put("download.extensions_to_open", "application/xml");// NOI18N
chromePrefs.put("safebrowsing.enabled", "true");// NOI18N
    ChromeOptions options = new ChromeOptions();
options.addArguments("--safebrowsing-disable-download-protection");// NOI18N
options.addArguments("safebrowsing-disable-extension-blacklist");// NOI18N

This is affecting my automation script. anyone aware of mitigation for this?

Vijay Shinde

unread,
May 3, 2021, 10:45:22 AM5/3/21
to ChromeDriver Users

Hi Ashwin,

Just sharing my experience here.
The below source code has helped me on windows machine to skip the download issue like "This file may harm your computer prompt".
You may try and check below code before opening webdriver instance,

HashMap<String, Object> prefs = new HashMap<String, Object>();

//to disable browser notification pop up
prefs.put("profile.default_content_setting_values.notifications", 2);  

//to disable the chrome browser prompt download file xml is harm to keep it
prefs.put("download.prompt_for_download", false);
prefs.put("download.extensions_to_open", "application/xml");
prefs.put("safebrowsing.enabled", true);
//to Turns off multiple download warning
prefs.put("profile.default_content_settings.popups", 0);
prefs.put("profile.content_settings.exceptions.automatic_downloads.*.setting", 1 );
//to set the default download file path
String downloadFilepath = System.getProperty("user.dir") + "\\src\\test\\resources\\downloads";
prefs.put("download.default_directory", downloadFilepath);

                                ChromeOptions options = new ChromeOptions();

options.setExperimentalOption("prefs", prefs);
options.addArguments("start-maximized");
options.addArguments("--safebrowsing-disable-download-protection");
options.addArguments("safebrowsing-disable-extension-blacklist");
WebDriver driver = new ChromeDriver(options);

Regards,
Vijay Shinde
Reply all
Reply to author
Forward
0 new messages