how to switch download directory using selenium / firefox / python?
You're initializing your browser with the default profile since you're not passing any profile argument to your webdriver.Firefox()
profile = webdriver.FirefoxProfile()profile.set_preference("browser.download.folderList", 2)profile.set_preference("browser.download.manager.showWhenStarting", False)profile.set_preference("browser.download.dir", directory)profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-gzip")driver = webdriver.Firefox(profile)
below options, it's working fine for me.
# set download optionsdownload_path = DOWNLOADS_PATH# 0 means to download to the desktop, 1 means to download to the default "Downloads" directory, 2 means to use the directoryfirefox_options.set_preference("browser.download.folderList", 2)firefox_options.set_preference("browser.download.dir", download_path)