'Python Selenium problem with downloading file, preferences its not ok
I've got problem. On the page after clicked button download, the window os with"Open and exported documents" shows. On this window I see two radio buttons: 1. Open file 2. Save file. Default is checked "Open file" but I would like to check "Save file" and next click "OK"
I've got this code, but it doesn't work correctly. Where is the mistake?
I've wiritten example_path in url. It's unreal path.
import os
from selenium import webdriver
url = "https://example_path"
profile = webdriver.FirefoxProfile()
driver_csv = webdriver.Firefox(firefox_profile=profile, executable_path= r"Desktop/programs/folder/geckodriver.exe")
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.download.manager.showAlertOnComplete", False)
profile.set_preference("browser.download.dir", os.getcwd())
profile.set_preference('browser.helperApps.neverAsk.openFile', "application/csv, text/csv, text/comma-separated-values")
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', "application/csv, text/csv, text/comma-separated-values")
profile.set_preference("plugin.disable_full_page_plugin_for_types", "application/csv, text/csv, text/comma-separated-values")
profile.set_preference("browser.download.useDownloadDir", True)
# profile.set_preference("pdfjs.disabled", False)
profile.set_preference("browser.tabs.warnOnClose", False)
driver.get(url)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
