How to download XLSX file through firefox using Selenium in Java? How to download XLSX file through firefox using Selenium in Java? selenium selenium

How to download XLSX file through firefox using Selenium in Java?


Instead of the above code I added following:

firefoxProfile.setPreference("browser.download.dir",dest_path);firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false);firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/xls;text/csv");

And now it is working fine. The MIME type for xlsx was not working properly so instead i tried to put the MIME type for xls file and now it is working fine. The XLSX file is getting downloaded automatically.


Just use this code:

profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")


Looks like MIME type for file that you are downloading is different (may be something like application/force-download ), as you have mentioned correct MIME type for xlsx - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.

Install "HTTPFox" Firefox plugin to record the traffic and check the actual MIME type captured in it. Once update with that MIME type, your code should work.