Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorey/366ef67fc7384f300dfc31f7800e45ba to your computer and use it in GitHub Desktop.
Save lorey/366ef67fc7384f300dfc31f7800e45ba to your computer and use it in GitHub Desktop.
Selenium: Prevent download dialog and download file automatically
# adapted from http://stackoverflow.com/a/25251803
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2) # custom location
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/vcard') # type of file to download
# use the out folder of the script path
profile.set_preference('browser.download.dir', os.path.join(os.path.dirname(os.path.abspath(__file__)), 'out'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment