Selenium: Easy way to handling file download dialog box

Do you think we can solve “file download pop-up  handling” problem easily in automation jargon?

Did you try different methods? How? what ?

I am using selenium and PERL for functional tests automation and I wrote AutoIT script to handle file download events.

Perl process for AutoIT script waits for File download windows and when it appears it clicks on particular button to save the file at predefined or default folder.  This is three-steps process – 1.)  Create process that waits for file download event, 2. ) Selenium action to click a link, 3.) Back-end process  wakes up and clicks on button on pop-up windows.

Instead of using these three-steps process, now I am using one step process – Click on link by selenium and file gets saved at predefined location.  To achieve file download in one step, you need to change your browser settings.

Firefox Settings.

1.  [Optional Step] Change the file download location.

  • Open FF browser and go to Tools->Options.  It will open Firefox properties windows.
  • Click on “General” Tab and go to Downloads settings.
  • [Optional ]  Uncheck first option that is “Show the Downloads Windows when downloading a file.
  • [Optional] Close it when all downloads are finished.
  • [optional] Save files to ….    Change location.
  • Do not click “Always ask me where to save files” radio button.

Step 1
2.  [Optional] Do you want to clear browser cache automatically when you close the browser ?

  • Set the  option Tools->Options
  • Click on Privacy Tab and select “Never Remember History” option from History part.

Step 2
3.  Now go to your HTTP server and download any file manually.  i.e Microsoft Word file –  1.doc.

  • When you click on link 1.doc, browser will pop-up with some options like “Open” or “Save”
  • Select Save option.
  • There is another option bellow “Save” radio button.  “Do this automatically for files like this from now on.
  • Check it and click on OK button.
  • File will be saved at predefined “Download” folder.

Step 3
4. Now click on browser option Tools->Options

  • Click on “Application” Tab
  • Search for “Microsoft office word 97…” from Content Type List.
  • Change Action to “Save File”.  [Default option is ” Always ask”]

Step 4
5. Repeat the steps 3 and 4 for all files your going to download through script in your “AUTOMATION” world.

That’s it.

Now verify this setting works or not.

  • Remove 1.doc from download folder.
  • Go to HTTP server and click on 1.doc link.
  • File will be downloaded automatically. It will not ask user to click on save button.


Now do you think,  you need to write AutoIT script to handle file download event?

If you find this information useful, do not forget to write your comment.



Filed under Automation

10 responses to “Selenium: Easy way to handling file download dialog box

  1. Vishwambhar

    this detailed information really helped



  2. Vasavi

    Even though I set the above options, when running script, it just ends at opening dialog. Earlier it used to provide the option to save or open. Now, it want to save, but asks for location. I did manually select the option to do so for all files from now. I don’t know what is the mistake I am doing. Can you please help.



    • Go To Options Menu and check the downloads options.
      There are three choices.
      1. Show the Downloads window when downloding a file.
      2. Save files to…
      3. Alwasy ask me where to save files.

      You should select option # 2 and set folder where you want to save file.
      Next time it will not ask you … where to save file.

      Let me still you need help.Save


  3. Ramasai

    Hi Can you please let me know if I can use something something similar to this in IE as well. I’m using Selenium RC to code.


  4. deepali.bansal

    how to do the similar settings in Internet explorer.
    I am unable to configure that


  5. Rajesh

    I done with the steps you provided above.. But How to change the settings for firebox browser opened by Web-driver. Those changed settings are not getting reflected in browser opened by selenium webdriver..

    Waiting for your reply


  6. Pingback: How To Solve Popup Issues in Selenium | Tech Travel Hub

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s