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

0
0

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 http://selenium.googlecode.com/files/selenium-server-standalone-2.33.0.jar)
  3. Give the desired location to save that file.

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

  • You must to post comments
0
0

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:

firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv");

See this Mozilla KB FAQ article on About:configs.

UPDATE
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.
Name*
E-mail*
Website