firefox (on windows) DL path in browser prefs has issues

335 views
Skip to first unread message

jw

unread,
Sep 16, 2011, 8:18:55 PM9/16/11
to Watir General
ruby 187
selenium-webdriver (2.6.0)
watir (2.0.1)
watir-webdriver (0.3.3)

It looks like FF (3.6.6) has some issues with the DL path setting:
browserProfile['browser.download.dir'] = "C:\my\new\dir"

1) it seems the string you pass must use backslashes and must contain
the drive letter

2) this example path will not work because webdriver first makes a
file called user.js which has a line like:
user_pref("browser.download.dir", "C:\my\new\dir");

but when FF starts up it creates prefs.js which will have a line like:
user_pref("browser.download.dir", "C:\\my\new\\dir");

where the \ before the 'n' is lost. It does the same thing for '\r'
so I put in a hack in my classExtensions file that looks like:

module Selenium
module WebDriver
module Firefox
class Profile
def write_prefs(prefs, path)
File.open(path, "w") { |file|
prefs.each do |key, value|
if (key['download'] and value.kind_of?(String))
value.gsub!(/\\n/, '\\\\\\n')
value.gsub!(/\\r/, '\\\\\\r')
end

file.puts %{user_pref("#{key}", #{value});}
end
}
puts path
end
end
end
end
end

Alister Scott

unread,
Sep 17, 2011, 6:34:24 AM9/17/11
to watir-...@googlegroups.com
Thanks SO much for this.
I was experiencing this EXACT same problem yesterday and it was driving me nuts!
With this patch, will it also work with a newer version of Firefox?

jw

unread,
Sep 21, 2011, 12:54:13 PM9/21/11
to Watir General
You're an OSX user, true? So this is happening there as well?

jw

unread,
Sep 21, 2011, 4:58:52 PM9/21/11
to Watir General
Successfully tested the above patch on FF6.0.2 on XP. I saw the
'double escaping' patch you/he recommended in your change request but
I'm sticking to this for the time being... works on my machines :)

Alister Scott

unread,
Sep 21, 2011, 10:25:48 PM9/21/11
to watir-...@googlegroups.com
Yes, OSX user and not happening on OSX
Was running tests at a client site using Windows XP desktop machine

Reply all
Reply to author
Forward
0 new messages