Setting Firefox Preferences to Save PDFs to File Directly in SeleniumLast updated:
If your application involves downloading files, you want to include that in your functional tests too. If you, however, don't configure the Selenium Driver, the default behaviour (for the Firefox Client at least) is to open up a dialog and require that you select whether you want to download, to open and so on.
This is how you configure Firefox from within Selenium so that PDF downloads get downloaded automatically to a directory you specify (in my example, downloads go to
/tmp). If you don't do this and you trigger a download from within your app, then you'll need to (manually) click on the dialogs that come up.
profile = Selenium::WebDriver::Firefox::Profile.new profile['browser.download.folderList'] = 2 #custom location profile['browser.helperApps.neverAsk.saveToDisk'] = "application/pdf" profile['browser.download.manager.showWhenStarting'] = false profile['browser.download.manager.useWindow'] = false profile['browser.download.dir'] = '/tmp' profile['pdfjs.disabled'] = true DRIVER = Selenium::WebDriver.for :firefox , :profile => profile