I’ve been using Selenium with Python to download files from a website that blocks direct HTTP requests. My setup worked fine for a while but recently hit a snag.
The problem is that I can’t seem to turn off the ‘Save As’ popup when trying to download files in headless mode. This popup is getting in the way and stopping the downloads.
I’ve dealt with this headache before, and it can be frustrating. One thing that worked for me was switching to Firefox instead of Chrome. Firefox seems to handle headless downloads better in my experience.
Here’s what I did:
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
This approach bypassed the download prompts for me. Just make sure you have the latest geckodriver installed. Also, you might need to tweak the MIME types in the ‘neverAsk.saveToDisk’ preference depending on your file types.
Hope this helps! Let me know if you need any clarification.
I’ve encountered similar issues with Selenium headless downloads. One effective workaround I’ve found is using the Chrome DevTools Protocol (CDP) to intercept and handle download requests. This method bypasses the Save As dialog entirely.
This approach has proven more reliable for me in recent versions of Chrome. It’s worth noting that you may need to adjust your code to wait for the download to complete, as headless downloads can be asynchronous.
hey dancingbird, i’ve hit this issue too. headless mode can be tricky with downloads. have u tried using a custom chrome profile instead? it might bypass the popup. also, check if the site changed anything recently. sometimes they tweak stuff to block automation. gl!