0

I was using Firefox 58.0, but have just updated to 60.1.0esr. Since upgrading, when I attempt to download a csv file, the "choose download location" box appears. This did not happen in 58.0.

I start Firefox with a fresh profile, which is set to never ask for download location for csv downloads:

browser.download.dir => "<a directory>"
browser.download.folderList => 2
browser.helperApps.neverAsk.saveToDisk => "text/plain,text/csv"

I can't find any suggestion that the profile settings required to disable the download location prompt have changed between 58.0 and 60.1.0esr, so I don't know why this is occurring. Can anyone shed some light on the problem?

paulmdavies
  • 1,248
  • 3
  • 12
  • 28
  • See this discussion https://stackoverflow.com/questions/45589571/auto-download-in-firefox-browser-with-java-selenium-not-working/45590783#45590783 – undetected Selenium Jul 24 '18 at 11:56
  • @DebanjanB thanks, but that's a different problem. It was working fine for me on Firefox 58 but broke when I upgraded to 60; 60 wasn't released until after your answer so it can't pertain to this problem. – paulmdavies Jul 24 '18 at 13:34

2 Answers2

0

Add application/octet-stream as well,

profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv,application/octet-stream");
profile.setPreference("browser.helperApps.neverAsk.openFile","text/csv,application/octet-stream");

It worked for me in FF 61.0.1.

Hope this works

Bhargav Marpu
  • 296
  • 1
  • 6
  • This doesn't help, and I wouldn't expect it to, since the 'Content-Type' header for the download is 'text/csv'. – paulmdavies Jul 24 '18 at 15:58
  • application/octet-stream for all file types, text/csv may or may not be recognized in all cases. – Bhargav Marpu Jul 24 '18 at 16:00
  • Be that as it may, adding that 'application/octet-stream' doesn't fix the problem. – paulmdavies Jul 24 '18 at 16:01
  • Similar issue I faced but in case of PDF download, after upgrading to ff 60 my script didn't work. updating preferences worked later. Tried the same approach for csv and worked for me. updated the above preferences in Firefox in about:config and file downloaded without prompting and even validated with the script. It may not work with test/csv alone even if that is header as the issue is not with csv alone. – Bhargav Marpu Jul 24 '18 at 16:12
0

The problem turned out to be that my Firefox profile, which was being auto-generated, had \n characters in place of newlines:

user_pref("browser.download.dir", "/tmp/tmpesIUnd");\nuser_pref("browser.download.folderList", 2);\nuser_pref("browser.helperApps.neverAsk.saveToDisk", "text/plain,text/csv");

For Firefox 60, the parsing of user preferences has been made stricter, and these \n characters are rejected. This is an expected change, so I've fixed my profile generator to produce the file correctly.

paulmdavies
  • 1,248
  • 3
  • 12
  • 28