I am writing a script using Selenium to export an XML backup from the export page of a MediaWiki-based website.
I wish to download the XML file to a directory, bypassing the popup window that usually asks me what to do with the file.
When I look at the Network tab when downloading the .xml, file I see (under Response Headers) that content-type is application/xml; charset=utf-8.
Screenshot from Network tab on Firefox
After reading some answers here, as well as this reddit post, I am using:
fp = webdriver.FirefoxProfile()
fp.set_preference("browser.preferences.instantApply",True)
fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/plain, application/octet-stream, text/xml, application/xml")
fp.set_preference("browser.helperApps.alwaysAsk.force",False)
fp.set_preference("browser.download.manager.showWhenStarting",False)
fp.set_preference("browser.download.folderList",2)
driver = webdriver.Firefox(firefox_profile=fp, executable_path=r'C:\Python37\geckodriver.exe')
(...)
download_button.click()
However, the window still pops up and the file is not downloaded anywhere.
I made sure to update Selenium and the geckodriver.
What am I doing wrong?
Thank you!