i want to auto download files and save them in directory, everything is done but firefox stills save files in User download folder e.g. C:\users\root\Downloads
the function in class PyWebBot
@staticmethod
def FirefoxProfile(path, handlers):
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.folderList",1)
profile.set_preference("browser.download.manager.showWhenStarting",False)
profile.set_preference("browser.download.dir", path)
profile.set_preference("browser.download.downloadDir", path)
profile.set_preference("browser.download.defaultFolder", path)
profile.set_preference("browser.helperApps.alwaysAsk.force", False)
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", handlers)
profile.set_preference("pdfjs.disabled", True)
profile.update_preferences()
return profile
then
def setUp(self):
self.profile = PyWebBot.FirefoxProfile(config['downloads'], config['handlers'])
self.driver = webdriver.Firefox(self.profile)
...
...
config:
config['downloads'] = 'Q:/web2py_src/web2py/applications/internet2letter/private/testing/selenium/downloads'
config['handlers'] = 'application/pdf'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With