Home >Backend Development >Python Tutorial >How to Fix Download Issues in Chrome Headless Mode?

How to Fix Download Issues in Chrome Headless Mode?

Patricia Arquette
Patricia ArquetteOriginal
2024-11-05 14:41:02347browse

How to Fix Download Issues in Chrome Headless Mode?

How to Download Files in the New Chrome Headless Mode

Problem

When automating downloads using Selenium and Chrome 59 in headless mode, the downloads do not start.

Solution

To fix this issue, switch to the new Chrome headless mode using the appropriate headless flag:

Chrome 109 and above:

<code class="python">options = webdriver.ChromeOptions()
options.add_argument("--headless=new")</code>

Chrome 96 through 108:

<code class="python">options = webdriver.ChromeOptions()
options.add_argument("--headless=chrome")</code>

By enabling the new headless mode, you restore the full functionality of Chrome, including the ability to perform downloads.

The above is the detailed content of How to Fix Download Issues in Chrome Headless Mode?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn