Download files in Chrome browser using selenium WebDriver


There are situations where we need to

  • Download files from browser,
  • Save in a specified folder on hard disk.

We will be taking help of ChromePreferences, ChromeOptions and DesiredCapabilities of Chrome in selenium.

Find below code to download files in Chrome browser:

Find the downloaded file under the specified folder – c:\download

Content posted is based on learning or working experience, Share the post with others if find useful, Any queries?, leave comments or discuss on our, Thanks!

6 Responses

  1. Hussain says:

    By using Robot class, we can achieve this easily…

    if Save Button is Highlighting in Download popup:
    Robot r=new Robot();

  2. NAMBIAR says:

    Hello, I tried exactly the same solution and it’s showing me the Save window. Then I sued the Robot key event and it’s downloading to the user default download folder and NOT to the custom download directory.

  3. Ed B says:

    Line 17 is empty because line 11 is instantiated but never assigned.

  4. Anonymous says:

    Chrome doesnot launch save window….mozilla does…this code is for chrome and not mozilla……mozilla has diff code……I tried this and this is working absolutely fine for me…..i opened my folder that i gave path for downloading…… downloaded in that particular folder itself

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: