I was recently unsuccessfully trying to set the Firefox download directory on Windows using a Watir-WebDriver/Selenium-WebDriver profile. Thanks to a comment on this blog, it turns out there is a bug whereby if your download path contains a \n or \r, then it reverts back to the default location.
So, a download path like “C:\new\raw” will fail without telling you why.
Fortunately, it’s now been fixed, but hasn’t been released, so in the meantime, you can double escape it
require 'watir-webdriver' p = Selenium::WebDriver::Firefox::Profile.new p['browser.download.dir'] = "C:\\\\new\\\\raw" p['browser.download.folderList'] = 2 p['browser.helperApps.neverAsk.saveToDisk'] = "application/pdf" b = Watir::Browser.new :firefox, :profile => p