1

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?"

JorgeAmVF
  • 1,660
  • 3
  • 21
  • 32
awkward
  • 37
  • 1
  • 1
  • 6
  • can u try `options.addArguments("disable-popup-blocking");` check this for more https://www.browserstack.com/automate/java#enable-disable-popups – NarendraR Jan 12 '18 at 04:27
  • thanks for your reply. Tried with `options.addArguments("disable-popup-blocking")` still no luck...:( – awkward Jan 12 '18 at 14:38

1 Answers1

0
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);