I'm using selenium (Python) to fetch some data from a website, at some point I access a link that downloads a file. How do I configure webdriver (Firefox) so that it automatically accepts the download, without which I need to click download?
I'm using selenium (Python) to fetch some data from a website, at some point I access a link that downloads a file. How do I configure webdriver (Firefox) so that it automatically accepts the download, without which I need to click download?
Use FirefoxProfile
to configure your Firefox before instantiating the browser :
from selenium import webdriver
import os
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("browser.download.folderList",2)
firefox_profile.set_preference("browser.download.manager.showWhenStarting",False)
firefox_profile.set_preference("browser.download.dir", os.getcwd())
firefox_profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream")
browser = Firefox(firefox_profile = firefox_profile)