There are a lot of questions out there regarding using Selenium to test the downloading of files. The answers of which are generally, "DON'T!". For those that don't take no for an answer, the sub-answer is "Don't download by clicking the link. Instead, get the HTTP response from the link's URL". They also point to this article a lot.

My issue is that in the web app I'm testing, there is never a link to the file being downloaded. The buttons start a process to dynamically generate a file that is then sent to the browser (think CSV and PDF reports).

This means that to accurately test the site, Selenium must click the button to start the process and then wait for the download.

And while some browsers will just automatically download the file, Edge and IE for instance always pop-up a "What do you want me to do" box which stops the test from completing.

AutoIT and such add-ons are out because the tests run on multiple different Operating Systems.

How can someone reliably download a file in a cross-browser, cross-platform fashion?

Bonus points if the file can be redirected to a known location for inspection (to validate the the info in the CSV matches what is expected).


ElementalSelenium suggest to configure your browser instance to bypass the dialog box (by creating advanced profile).

Linked example is for Ruby, but creating the profile should be similar for Java too.

  • While a possible answer, this one is FireFox-specific. I'm looking for either a single cross-browser solution, or barring that, a set of solutions for each browser. – MivaScott Jan 3 '18 at 18:09

Your Answer

