Reputation: 37
I know this question was asked here How to disable 'This type of file can harm your computer' pop up But the post also says the given solution does not work for all the chrome version.
I tried every possible thing still can not disable the pop up or select keep the file button.I am using chrome Version 62.0.3202.89 (Official Build) (32-bit)
I used below code but not working...:(
HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
chromePrefs.put("profile.default_content_settings.popups", 0);
chromePrefs.put("download.default_directory", downloadDir);
options.setExperimentalOption("prefs", chromePrefs);
chromePrefs.put("safebrowsing.enabled", "true");
options.addArguments("--safebrowsing-disable-download-protection");
//options.addArguments("--test-type");
// options.addArguments("--disable-extensions"); //to disable browser extension popup
//options.addArguments("--safebrowsing-disable-extension-blacklist");
Please help if anyone knows how to make the download start when chrome warning pops up saying "This type of file can harm your computer.Do you want to keep the jar anyway?"
Upvotes: 1
Views: 14328
Reputation: 3758
In Chrome, version 132, the correct way to disable the Save popup in python is this:
chrome_options = Options()
chrome_options.add_argument("--disable-popup-blocking")
driver = webdriver.Chrome(options=chrome_options)
driver.execute_cdp_cmd("Page.setDownloadBehavior", {
"behavior": "allow",
"downloadPath": download_dir
})
Feel free to modify this answer for Java.
Upvotes: 0
Reputation: 31
DesiredCapabilities cap;
ChromeOptions options = new ChromeOptions();
String downloadFilepath = "K:\\";
HashMap<String, Object> setPath = new HashMap<String, Object>();
setPath.put("download.default_directory", downloadFilepath); //to set path
setPath.put("safebrowsing.enabled", "false"); // to disable security check eg. Keep or cancel button
HashMap<String, Object> chromeOptionsMap = new HashMap<String, Object>();
options.setExperimentalOption("prefs", setPath);
options.addArguments("--disable-extensions"); //to disable browser extension popup
cap = DesiredCapabilities.chrome();
cap.setCapability(ChromeOptions.CAPABILITY, chromeOptionsMap);
cap.setCapability(ChromeOptions.CAPABILITY, options);
Upvotes: 0