2

I don't want to handle download window in Firefox or IE. I want to auto download the excel file without any download window. I have tried to set several configuration parameters for Firefox, but it didn't work. In my test I'm trying to download excel file

profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.lastDir'] = 'C:\\Downloads'
profile['browser.download.folderList'] = 2
profile['browser.download.dir'] = 'C:\\Downloads'
profile['download.prompt_for_download'] = false
profile['browser.download.manager.showWhenStarting'] = false
profile['browser.download.manager.addToRecentDocs'] = true

profile['browser.download.manager.useWindow'] = false
profile['browser.download.useDownloadDir'] = true
profile['browser.download.show_plugins_in_list'] = true
profile['browser.download.manager.openDelay'] = 100000
profile['browser.download.animateNotifications'] = false

driver = Watir::Browser.new :firefox, :profile => profile

Still the browser displaying download window when my script performs click operation on download button

Currently I'm using Firefox 35.0.1 on Windows-7(64bit)

Shiv
  • 307
  • 1
  • 16

1 Answers1

2

As per documentation, you should use the browser.helperApps.neverAsk.saveToDisk preference to achieve this. Value is defined as

A comma-separated list of MIME types to save to disk without asking what to use to open the file. Default value is an empty string.

I am not very good at Ruby, but it will probably look something like

profile["browser.helperApps.neverAsk.saveToDisk"] = "text/plain, application/octet-stream"

Just use the correct MIME type.


I also found this, this and this answer.

Community
  • 1
  • 1
Erki M.
  • 5,022
  • 1
  • 48
  • 74