Configure webdriver Firefox in Selenium

1

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?

    
asked by anonymous 05.04.2017 / 17:14

1 answer

0

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)
    
05.04.2017 / 17:48