Senseful
Senseful

Reputation: 91711

How to download multiple files on Chrome with Capybara/Selenium?

I am using Capybara with Chrome and Selenium. When I attempt to click on a link that causes an automatic download, the file is downloaded correctly. If I try to do this again, Chrome shows the message: "This site is attempting to download multiple files. Do you want to allow this?"

enter image description here

I was looking for a flag that could be used to disable this message, but couldn't find anything. Is there any way I can get around this message and allow the multiple download without having to resort to a page refresh? (E.g. Is there any way I can click the Allow button programmatically?)

Upvotes: 6

Views: 2405

Answers (2)

Ravinath Edirisinghe
Ravinath Edirisinghe

Reputation: 75

Use Chrome Options

WebDriver driver = null;
ChromeOptions options = new ChromeOptions();
        Map<String, Object> prefs = new HashMap<String, Object>();
        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);
        options.setExperimentalOption("prefs", prefs);

    driver = new ChromeDriver(options);

Upvotes: 0

St.Zelenin
St.Zelenin

Reputation: 30

Please see my work-around here:

https://code.google.com/p/chromedriver/issues/detail?id=130#c12

Upvotes: 1

Related Questions