Disable chrome download multiple files confirmation

后端 未结 9 1409
太阳男子
太阳男子 2020-12-02 01:57

I developed a crawler with ruby watir-webdriver that downloads some files from a page. My problem is that when I click to download the second file, Chrome opens a bar in the

9条回答
  •  独厮守ぢ
    2020-12-02 02:18

    Here is the solution for Java - Selenium implementation

    We faced hard time fixing this, as we wanted to add automation test for functionality which downloads set of PDFs on a single download link.

    Map prefs = new HashMap();
    //To Turns off multiple download warning
    prefs.put("profile.default_content_settings.popups", 0);
    prefs.put( "profile.content_settings.pattern_pairs.*.multiple-automatic-downloads", 1 );
    //Turns off download prompt
    prefs.put("download.prompt_for_download", false);
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOptions("prefs", prefs);
    driver =  new ChromeDriver(options);
    

    Hope this help to someone.

提交回复
热议问题