Browser Downloads

Edit on GitHub

The easiest and best way of dealing with file downloads is to avoid the pesky file download dialogs altogether. This is done by programatically telling the browser to automatically save files to a certain directory, that your test can access.


download_directory = "#{Dir.pwd}/downloads"!('/', '\\') if

profile =
profile[''] = 2 # custom location
profile[''] = download_directory
profile['browser.helperApps.neverAsk.saveToDisk'] = 'text/csv,application/pdf'

b = :firefox, profile: profile

A full list of these Firefox options are available in firefox by typing ‘about:config‘ in the address bar.

If you want to know a way to work out the file types (eg. application/pdf) then you can read the following blog post for an step by step guide.


prefs = {
  download: {
    prompt_for_download: false,
    default_directory: '/path/to/dir'

b = :chrome, options: {prefs: prefs}

See a full list of Chrome preferences