14

I have problem with Selenium WebDriver and Firefox. I want to download csv file without confirmation in dialog window and I have code like this:

fp = webdriver.FirefoxProfile() fp.set_preference("browser.download.folderList",2) fp.set_preference("browser.download.dir", download_dir) fp.set_preference("browser.download.manager.showWhenStarting",False) fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/csv") 

but it seems not working. I tried many combination with browser.helperApps.neverAsk.saveToDisk

fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/csv,application/csv,text/plan,text/comma-separated-values") 

or

fp.set_preference("browser.helperApps.neverAsk.saveToDisk","application/csv") fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/plain") fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/comma-separated-values") 

but there's no difference and Firefox won't download automaticly. How can I fix it?

2
  • Yes, that was problem with a wrong MIME type, thanks! Commented Sep 14, 2013 at 16:16
  • can anyone help me? [enter link description here][1] [1]: stackoverflow.com/questions/27058053/… Commented Nov 21, 2014 at 11:43

3 Answers 3

15

Sometime the content type is not as you'd expect Use HttpFox Firefox plugin (or similar) to find the real content type of the file and use it in your code

BTW, For me the content type was

fp.set_preference("browser.helperApps.neverAsk.openFile", "application/octet-stream"); fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream"); 
Sign up to request clarification or add additional context in comments.

1 Comment

I faced the same issue as @nanoo. Used HttpFox & determined that the mime type was application/msexcel. Works now! Thanks!
1

SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/comma-separated-values ,text/csv"); //in java selenium this will work for downloading all type of csv files... thanks, enjoy....

Comments

0

Now (May 2016),

 SetPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv"); // C# 

works for me

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.