'Chromedriver for Chrome 77 is supposed to support headless downloads, but download still doesn't work

On the ChromeDriver downloads page (https://chromedriver.chromium.org/downloads) it lists "Support to save file downloads in headless mode" as a feature for ChromeDriver supporting Chrome 77.

I installed Chrome 77 (https://www.google.com/chrome/beta/) and downloaded the new ChromeDriver. I'm on a Mac with Mojave 10.14.5.

However, the download does not get saved when I am in headless mode. If I do not use headless mode, the file saves as expected.

According to my logging I am successfully clicking the "Download" just like in non-headless mode:

Element found with locator: //button[contains(text(), 'Download All as CSV')] and locator type: xpath

Clicked on element with locator: //button[contains(text(), 'Download All as CSV')] locatorType: xpath

but nothing gets downloaded. There are no errors or exceptions.

I have tried implementing various workarounds including this one https://github.com/shawnbutton/PythonHeadlessChrome/blob/master/driver_builder.py without any luck, both before updating Chrome/ChromeDriver and after.

All my other tests work fine in headless mode, just not the download.

I am wondering if anyone else has had success with the new ChromeDriver, or if anyone has other strategies for me to try - perhaps there is further logging/debugging I can add in to pinpoint the issue?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source