How to download any file and save it to the desired location using Selenium Webdriver


I have to perform following task using Selenium Webdriver given below.

  1. Click on any link/button that start downloading any file (filetype may be anything image, pdf, jar etc)
  2. Click on the “Save” on popup if appeared (e.g. in case of
  3. Give the desired location to save that file.

Can anyone share, how can we implement this using Java?

  • You must to post comments

You won’t be able to access the save dialog box. That’s controlled by the OS. The only thing you’re really going to be able to do is set the default download location for the browser and allow it to automatically download the files. Then check the file in Java.

You should check this answer from this previous SO question. Basically when setting up your Firefox profile you add a call to set the property browser.helperApps.neverAsk.saveToDisk to a comma separated list of MIME types to always download:


See this Mozilla KB FAQ article on About:configs.

It looks like this may now be possible see this answer in another question

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.