protractor
protractor copied to clipboard
Chrome sendChromiumCommand 'Page.setDownloadBehavior' failing - UnsupportedOperationError
Bug report
- Node Version:
10.16.0 - Protractor Version:
5.4.2 - Angular Version:
8 - Browser(s):
Chrome (headless / normal) - Operating System and Version
Windows 10 - Your protractor configuration file
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: useHeadlessBrowser ? ["--headless", "--window-size=1920,1080"] : undefined,
useAutomationExtension: false,
// Set download path and avoid prompting for download even though
// this is already the default on Chrome but for completeness
// https://chromium.googlesource.com/chromium/src/+/master/chrome/common/pref_names.cc
prefs: {
"download": {
"prompt_for_download": false,
"directory_upgrade": true,
"default_directory": downloadDirectory,
"download_directory": downloadDirectory,
"download_dir": downloadDirectory,
"download_restrictions": 0,
}
}
}
},
Before any tests run I send the below command to Chrome to enable file downloads in headless Chrome
// returns full path
const downloadDirectory = Utils.getTempDirectoryPath();
Utils.log(`Setting Chrome download behaviour to directory ${downloadDirectory}`);
browser.driver.sendChromiumCommand('Page.setDownloadBehavior', {
behavior: 'allow',
downloadPath: downloadDirectory
});
This has stopped working on Chrome 74+ with the error.
UnsupportedOperationError: POST /session/ac771ec3019f7b4c7191e2c9ae2b2056/chromium/send_command
We are unable to run test on Chrome 74 now and cannot get any of our file download tests to work as headless Chrome is unable to download a file with issuing the above command.
Is there any other suggested way to enable file downloads in headless Chrome without issuing the above command?
Even I am facing the same issue with same error UnsupportedOperationError: POST /session/f397ed9f1895f4ff384b4c57fab31580/chromium/send_command
Node Version: v10.15.1 Protractor Version: 5.4.2 Browser(s): Chrome (headless / normal) - 76.0.3809.87 Operating System and Version Windows 10
Also having this issue.
Any movement on this?
I have run into this issue also.
@jonsamwell, as i see you're using chrome 76, the capabilities set for chrome doesn't work as it expects chrome options in W3C mode.
By Default, from chrome 74+, it strictly follows W3C compliant commands.
@Harsha509 what does this mean in practice?
Hi @jonsamwell ,
In practiece chromeOptions{} may not work as now chrome 74+ expects options to be in w3c format -> goog:chromeOptions{}
you can refer to w3c doc for this change https://www.w3.org/TR/webdriver/#extensions-0 example 5:
You can give it a try by turning off W3C in chromeOptions: chromeOptions:{ 'args':[...], 'w3c': false, }
Thanks!
I made it work using this versions:
- Protractor: 5.4.2
- Selenium standalone server: 3.141.59
- Chrome: 77.0.3865.40
I launched Chome in headlles way and everything is fine. Actually, it seems like browser.driver.sendChromiumCommand(...) configuration is not longer necessary. I deleted it and everything works fine for me.
I did not try setting "w3c":false but with the versions I mention and deleting the configuration, everything seems to work.
I made it work using this versions:
- Protractor: 5.4.2
- Selenium standalone server: 3.141.59
- Chrome: 77.0.3865.40
I launched Chome in headlles way and everything is fine. Actually, it seems like
browser.driver.sendChromiumCommand(...)configuration is not longer necessary. I deleted it and everything works fine for me.I did not try setting
"w3c":falsebut with the versions I mention and deleting the configuration, everything seems to work.
Hi @BZaldua , can I check how did you define the default download directory without sending the chromium command?
@timothyjmtan
var path = require('path');
...
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [
'--headless', '--window-size=1280,720', '--no-sandbox'
],
prefs: {
download: {
'prompt_for_download': false,
'directory_upgrade': true,
'default_directory': path.resolve('./test/downloads/')
}
}
}
},
specs: [**/*.spec.js'],
framework: 'jasmine2',
plugins: [],
onPrepare: function () {
browser.protractorImageComparison = new ProtractorImageComparison({...});
...
}
}
Thanks @BZaldua !
Just following up here, @BZaldua's versions worked for me also.