Configure Firefox webdriver in Selenium

Asked

Viewed 1,215 times

3

I’m using Selenium (Python) to fetch some data from a site, at a given time I access a link that downloads a file. How to configure the webdriver (Firefox) to automatically accept the download, without which I need to click download?

1 answer

3

Use FirefoxProfile to configure your Firefox before instantiating 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)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.