Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox + Selenium WebDriver and download a csv file automatically

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?

like image 915
nanoo Avatar asked Sep 12 '13 08:09

nanoo


1 Answers

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....

like image 113
anonymous Avatar answered Oct 06 '22 04:10

anonymous