In an angular2+ project I have an e2e testcase that clicks a button, a file gets downloaded, and the content is checked. It works in normal mode, but not in --headless mode. The file is not downloaded, and the testcase times out.
In my protractor.conf.js I already tried a lot of flags I found in different places:
const os = require('os');
[...]
capabilities: {
'browserName': 'chrome',
chromeOptions: {
args: ['--headless', '--disable-gpu', '--disable-popup-blocking', '--no-sandbox', '--window-size=1024,768', '--remote-debugging-port=9222', "--disable-dev-shm-usage"],
prefs: {
'download': {
'prompt_for_download': false,
'directory_upgrade': true,
'default_directory': os.homedir() + '/Downloads'
},
safebrowsing: {enabled: false, disable_download_protection: true},
browser: {set_download_behavior: { behavior: 'allow' }}
}
}
},
Without success.
Also I read somewhere that you could configure it like this
// works for headless and "normal" mode
browser.driver.sendChromiumCommand('Page.setDownloadBehavior', {
'behavior': 'allow',
'downloadPath': DOWNLOAD_DIR
});
But there is no "sendChromiumCommand" in any "browser" variable, neither in the protractor.conf.js nor in the spec ts file.
How can I get this to work? Thanks in advance.
Just found the solution to this.
Add these lines to your
protractor.conf.js
:From: https://bugs.chromium.org/p/chromium/issues/detail?id=696481#c196