I am trying to install some files through a link using Selenium w/ Chrome. After numerous attempts to get around this and checking if any files were downloaded in my docker container using the find command on the root directory, I can confirm that no files were downloaded.
My current options look like this:
options = Options()
options.binary_location = '/usr/bin/google-chrome'
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--single-process')
options.add_argument('--disable-dev-shm-usage')
prefs = {
'download.default_directory' : '/tmp',
'download.directory_upgrade' : True,
'download.prompt_for_download': False
}
options.add_experimental_option('prefs', prefs)
browser = webdriver.Chrome('/opt/chrome/chromedriver', chrome_options=options)
And I am getting the files by opening a new tab and going directly to the download link, like this:
browser.execute_script(f"window.open('{download_link}';")
My script does download files correctly on my local Windows machine with minor edits on the options to accommodate for a Windows computer. I do need to do this on the same Selenium browser as I am trying to download some files from a tool's website which requires login, and the data I want to grab is not exposed by their API.
The browser doesn't seem to be the issue as the script is able to login and perform its actions without fail on the docker container itself, which I confirmed through my debug logs.
Things I have tried
I have already tried changing the download.default_directory to other paths, but to no avail. I have also tried changing options to webdriver.ChromeOptions(). I also set the browser's options = options instead of chrome_options=options as well.