0

I want to create automated test in selenium webdriver with cucumber to download some stuff and I am using a custom firefox profile, but it seems not to work when downloading jpg files. Can you help me with tips & tricks how to make jpg files to be downloaded automatically instead of the download manager to show up? In Application tab I didn't find anything related to jpg files, and in General tab "Save files to" is set. My version of firefox is 34. When setting up the properties of the profile I've been using "image/jpeg" as mime type for jpg .

user3399858
  • 103
  • 1
  • 7
  • Show the current code you have so far. Thanks. – alecxe Aug 03 '15 at 14:21
  • ProfilesIni profile = new ProfilesIni(); FirefoxProfile myprofile = profile.getProfile("selenium"); myprofile.setPreference("browser.download.folderList",1); myprofile.setPreference("browser.download.manager.showWhenStarting",false); myprofile.setPreference("browser.helperApps.neverAsk.saveToDisk", "image/jpeg, application/x-msexcel, application/octet-stream"); driver = new FirefoxDriver(myprofile); – user3399858 Aug 03 '15 at 14:24
  • Note that "selenium" is the name of the custom profile and when downloading xlsx files it's working good. Thanks heaps. – user3399858 Aug 03 '15 at 14:25
  • Correct me if I am wrong. Currently, firefox opens up the "Save file" dialog? – alecxe Aug 03 '15 at 14:26
  • Yes, for jpg files it does. – user3399858 Aug 03 '15 at 14:27
  • Try setting the `browser.download.folderList` to `2` and play around with the mime-types more. – alecxe Aug 03 '15 at 14:31
  • Since I have set in firefox "Save files to" Downloads, and I set "myprofile.setPreference("browser.download.manager.showWhenStarting",false); " and I set the mime type, which is good for jpg files, I simply don't understand why the dialog box is still showing up when downloading jpg files. I have tried with "2" and with setting a custom folder too. – user3399858 Aug 03 '15 at 14:36

1 Answers1

1

I have updated my firefox version and it solved the problem, guess it was a firefox bug. Now in v39 JPEG appear in application tab and preferences can be set against it. Initially I didn't want to update firefox version because I thought it was another bug, from maven dependencies ${selenium.version} selenium didn't take the last version. I manually changed it to the last version from repo and it works.

user3399858
  • 103
  • 1
  • 7