'pyvirtualdisplay - downloads are stuck as .part file
I have a python-selenium script running on a debian 11 server without any Desktop - thats why i use pyvirtualdisplay. The script has to login to a website and then go to a page on this site that, on open, instantly downloads a xlsx file (no dialogue, direct download)
#!/usr/bin/env python
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
display.start()
browser = 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", '/updatescript')
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-gzip")
browser.get("https://example.com/login")
browser.find_element_by_class_name('name').send_keys("[email protected]")
browser.find_element_by_class_name('passwd').send_keys("password")
browser.find_element_by_class_name('btn-primary').click()
browser.get("https://example.com/download")
Note this isnt site specific but works that way on all similiar sites (only .part files are downloaded).
The second problem is that my download folder is ignored, the script always downloads in /tmp/mozilla_root0
What is the reason? Dialogue cant be as the downloads are always instantly
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|