I’ve been running automated file downloads using Selenium WebDriver in headless Chrome for several months without issues. Recently, the setup stopped working properly.
My use case involves accessing a site that blocks direct HTTP downloads with 403 errors. So I use headless Chrome to browse to the download pages and trigger file downloads by visiting the file URLs directly.
The issue started a few days ago - now Chrome shows a “Save As” dialog even though I have the download prompt disabled in my configuration. This breaks the automation since the headless browser gets stuck on the popup.
Here’s my current setup that was working fine until recently:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
import time
# Configure headless Chrome
browser_options = Options()
browser_options.add_argument("--headless")
# Set download preferences
browser_options.add_experimental_option("prefs", {
"download.default_directory": r"D:\\downloads\\",
"download.prompt_for_download": False,
"download.directory_upgrade": True,
"safebrowsing.enabled": True
})
# Initialize WebDriver
web_driver = webdriver.Chrome(
service=Service(ChromeDriverManager().install()),
options=browser_options
)
# Navigate to file URL for download
web_driver.get(file_download_url)
# Allow time for download
time.sleep(8)
Has anyone else encountered this problem recently? Is there a new Chrome setting I’m missing or a different approach that works better?
Chrome version 119+ introduced stricter download policies that can override selenium preferences. I ran into this exact scenario last month when my scraping scripts suddenly broke. The solution was adding --disable-web-security and --allow-running-insecure-content arguments, plus updating the prefs to include "profile.default_content_setting_values.automatic_downloads": 1. Also make sure you’re setting "profile.content_settings.exceptions.automatic_downloads.*.setting": 1 in your experimental options. The key is that Chrome now requires explicit permission for automatic downloads even in headless mode, so these additional settings force it to behave like the older versions.
Chrome 120 changed how it handles download prompts and I suspect that’s what hit you. I dealt with this exact frustration two weeks ago when all my automation broke overnight. The fix that worked for me was switching from experimental_option prefs to using the --auto-open-devtools-for-tabs flag combined with --disable-popup-blocking. More importantly, I had to add "plugins.always_open_pdf_externally": True and "profile.managed_default_content_settings.images": 2 to the prefs dictionary. The download behavior seems tied to how Chrome handles content types now, so forcing external handling bypasses the dialog completely. Also worth checking if your ChromeDriver version matches your Chrome version since mismatched versions can trigger unexpected security prompts.
had same issue last week! try adding --disable-features=VizDisplayCompositor and --disable-extensions flags to your options. also chrome updated recently so maybe add "profile.default_content_settings.popups": 0 to your prefs dict. worked for me after struggling for days