Hi Guys,
I am trying to download documents using Selenium with Python from Firefox to a specific folder but I cannot get my code to work as it keeps asking me if I want to download rather than just downloading, any ideas? My code is below.
timeout = 40
downloadPath = âC:\TestData_Automated Download Documentsâ
profile = webdriver.FirefoxProfile()
profile.set_preference(âbrowser.download.folderListâ, 2)
profile.set_preference(âbrowser.download.manager.showWhenStartingâ, False)
profile.set_preference(âbrowser.download.dirâ, downloadPath)
profile.set_preference(âbrowser.helperApps.neverAsk.openFileâ, âapplication/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.openxmlformats-officedocument.spreadsheetml.template, application/vnd.ms-excel.sheet.macroEnabled.12, application/vnd.ms-excel.template.macroEnabled.12, application/vnd.ms-excel.addin.macroEnabled.12, application/vnd.ms-excel.sheet.binary.macroEnabled.12â)
profile.set_preference(âbrowser.helperApps.neverAsk.saveToDiskâ, âapplication/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.openxmlformats-officedocument.spreadsheetml.template, application/vnd.ms-excel.sheet.macroEnabled.12, application/vnd.ms-excel.template.macroEnabled.12, application/vnd.ms-excel.addin.macroEnabled.12, application/vnd.ms-excel.sheet.binary.macroEnabled.12â)
profile.set_preference(âbrowser.helperApps.alwaysAsk.forceâ, False)
profile.set_preference(âbrowser.download.manager.alertOnEXEOpenâ, False)
profile.set_preference(âbrowser.download.manager.focusWhenStartingâ, False)
profile.set_preference(âbrowser.download.manager.useWindowâ, False)
profile.set_preference(âbrowser.download.manager.showAlertOnCompleteâ, False)
profile.set_preference(âbrowser.download.manager.closeWhenDoneâ, False)
desiredCapabilities = DesiredCapabilities.FIREFOX.copy()
desiredCapabilities[âfirefox_profileâ] = profile.encoded
driver = webdriver.Firefox(executable_path=âC:\Users\d.baldwin\AppData\Local\Programs\Python\Python37-32\Lib\geckodriver.exeâ,capabilities=desiredCapabilities)
Is there something that I am missing? I am trying to download Excel documents (.xlsx)
Thanks for the help in advance!
Dan