Automation · Blogroll · firefox · QA · selenium · Selenium-webdriver · watir-webdriver

Watir / Selenium Web Driver – Browser Downloads — Solution to download pdf files automatically in firefox 20+ version


Solution to download pdf files automatically in firefox 20+ version using Selenium webdriver or Watir webdriver



I have tried to save PDF files automatically using the below link —  and I have followed the same as per the mentioned page and reference website. But still the firefox browser not downloaded PDF files automatically.


In Firefox latest versions, They have added new function called as ‘Portable Document Format’ which causes the issue


Please try the below code for latest firefox versions.

download_directory = "#{Dir.pwd}/downloads"

download_directory.gsub!("/", "\\") if
profile =
profile[''] = 2 # custom location
profile[''] = download_directory
profile['browser.helperApps.neverAsk.saveToDisk'] = "text/csv,application/pdf"

profile[‘pdfjs.disabled’] = true
profile[‘pdfjs.firstRun’] = false

b = :firefox, :profile => profile
profile[‘pdfjs.disabled’] = true
profile[‘pdfjs.firstRun’] = false
These 2 lines are added. Thats it 🙂
Ruby · watir · watir-webdriver

Watir WebDriver — Handling New Window


1. You are in Parent Page.
2. Clicking link “Open” in Parent page.
3. It opens new window
4. You need to do actions  there and come back to your parent window


To Click the Link

require 'rubygems'
require 'watir-webdriver' :ff

To handle the New window and performing some actions within that window,

ff.window(:title,/TITLE of the new window/i).use do
puts ff.title #returns the new window title

within a loop The button belongs to Newly opened window.

puts ff.title #returns the parent window title