Created
April 1, 2017 10:05
-
-
Save lorey/366ef67fc7384f300dfc31f7800e45ba to your computer and use it in GitHub Desktop.
Selenium: Prevent download dialog and download file automatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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