Ruby Capybara and Firefox: download file without showing dialog

I am trying to get a Capybara session to automatically save downloaded files in Firefox without showing the open / save dialog.

This is my test code:

require 'capybara/dsl'
require 'selenium-webdriver'

cb = Capybara

cb.register_driver :my_firefox_driver do |app|
  profile = Selenium::WebDriver::Firefox::Profile.new
  profile['browser.download.dir'] = "~/Downloads"
  profile['browser.download.folderList'] = 2
  profile['browser.helperApps.alwaysAsk.force'] = false
  profile['browser.download.manager.showWhenStarting'] = false
  profile['browser.helperApps.neverAsk.saveToDisk'] = "text/csv"
  profile['csvjs.disabled'] = true
  Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
end

cb.current_driver = :my_firefox_driver

# just to check that we are reaching the correct URL
cb.visit "https://www.google.com/finance/historical?q=NYSE:IBM&startdate=Jan+1%2C+1980&enddate=Sep+18%2C+2014&num=30"
sleep(3)
# attempt a CSV download
cb.visit "https://www.google.com/finance/historical?q=NYSE:IBM&startdate=Jan+1%2C+1980&enddate=Sep+18%2C+2014&output=csv"
sleep(15)

      

Firefox version 30. I have tried various profile settings as well as several MIME types, to no avail.

Thanks in advance for any suggestions or solutions.

+3
ruby firefox selenium profile capybara


source to share


No one has answered this question yet

Check out similar questions:

499
How do I write a file in Ruby?
8
Firefox + Selenium WebDriver and automatically download the csv file
five
Capybara - visit () not working with firefox
1
Selenium C # Firefox 22 - "silent save file" from internet no longer works
1
Selenium 2.53: csv files are not loaded automatically using new Marionette Firefox driver
0
When trying to save a .jpg file, a dialog opens even though the Firefox user profile is not set to
0
Can't auto save file using Selenium Firefox
0
How to dismiss Firefox download dialog using WebDriver
0
auto download .dmg files in selenium firefox webdriver
0
How to download XLSX (excel) file via firefox using Selenium in Java?



All Articles
Loading...
X
Show
Funny
Dev
Pics