Headless Mode Download Issue with Selenium and Chrome
When automating downloads using Selenium in headless mode, download functionality ceases to work. This issue arises despite successful downloads in normal mode. Setting a default download path has no impact on headless mode operations.
The Solution: New Headless Mode
To resolve this issue, utilize the revised headless mode introduced by Chromium developers. This "new headless mode" mimics the full functionality of normal Chrome, including the ability to use extensions.
Chrome 109 and Above Usage:
<code class="python">chromeOptions.add_argument("--headless=new")</code>
Chrome 96-108 Usage:
<code class="python">chromeOptions.add_argument("--headless=chrome")</code>
By implementing this new headless mode, you can now leverage the complete capabilities of headless Chrome, including the ability to initiate downloads as intended.
The above is the detailed content of Why Can't I Download Files with Selenium in Headless Mode?. For more information, please follow other related articles on the PHP Chinese website!