I downloaded the latest version of chromium, to test out the headless feature.
When I run (as root, because I'm still testing things):
./chrome --no-sandbox http://cp7.awardspace.com/speed-test/awardspace-data1mb.zip
In the GUI terminal, it opens Chromium and downloads the file.
If I'm trying to run it headless, I enter the following:
./chrome --no-sandbox --headless http://cp7.awardspace.com/speed-test/awardspace-data1mb.zip
The terminal outputs some information, no window gets opened, but also: I don't have the file downloaded anywhere.
I have been scouting the internet and discussion groups for more information, but cannot find anything.
Is file downloading not working in headless mode for Chromium?
Note: Not exactly answer to the question, but solves the problem
I researched a lot on making headless chrome download with different parameters/options/preferences, but nothing worked. Then I used standard Java way of downloading file using Apache Commons's FileUtils
That's a reported bug in headless implementation: https://bugs.chromium.org/p/chromium/issues/detail?id=696481
In Java use following code :
Use ChromeDriverService and POST session/{sessionId}/chromium/send_command
JSON for POST:
C# Solution
Add reference to System.Net.Http and use NuGet to install Newtonsoft.JSON.
I was able to download files with chrome headless thanks to Chrome Remote Interface
Full code for integration with selenium could be found here https://github.com/cezarypiatek/Tellurium/blob/master/Src/MvcPages/SeleniumUtils/ChromeRemoteInterface/ChromeRemoteInterface.cs
More info about setDownloadBehavior and Chrome Remote interface https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-setDownloadBehavior