I have the following code:
element_search_field = browser.find_element_by_id(search_field_id)
op.set_preference("browser.download.folderList",2)
op.set_preference("browser.download.manager.showWhenStarting", False)
op.set_preference("browser.download.dir","C:\\Users\\user\\Selenium")
op.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream,application/vnd.csv")
downloadcsv = browser.find_element_by_css_selector('#downloadOCTable')
downloadcsv.click();
I am having trouble at the last line downloadcsv.click();
. I was hoping that changing "application/octet-stream,application/vnd.csv")
from "application/octet-stream,application/vnd.ms-excel")
would automatically save the .csv file to the downloads folder but i am still get the DialogBox. Is there anyway I can have it saved without the DiaglogBox?
Edit:
As suggested by @Prophet:
I had made these changes but i am still get the pop up
profile = FirefoxProfile() profile.set_preference("general.useragent.override", userAgent)
profile.set_preference("browser.download.dir", "C:\\Users\\[user]\\Selenium Options")
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/csv,application/excel,application/vnd.ms-excel,application/vnd.msexcel,text/anytext,text/comma-separated-values,text/csv,text/plain,text/x-csv,application/x-csv,text/x-comma-separated-values,text/tab-separated-values,data:text/csv")
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/xml,text/plain,text/xml,image/jpeg,application/octet-stream,data:text/csv")
profile.set_preference("browser.download.folderList",2)
profile.set_preference("browser.download.manager.showWhenStarting",False)
profile.set_preference("browser.helperApps.neverAsk.openFile","application/csv,application/excel,application/vnd.ms-excel,application/vnd.msexcel,text/anytext,text/comma-separated-values,text/csv,text/plain,text/x-csv,application/x-csv,text/x-comma-separated-values,text/tab-separated-values,data:text/csv")
profile.set_preference("browser.helperApps.neverAsk.openFile","application/xml,text/plain,text/xml,image/jpeg,application/octet-stream,data:text/csv")
profile.set_preference("browser.helperApps.alwaysAsk.force", False)
profile.set_preference("browser.download.useDownloadDir", True)
profile.set_preference("dom.file.createInChild", True)