I want to run e2e test of file download on Google Chrome. I referred to several posts including Protractor - Jasmine - Download file to a relative path, Protractor e2e test case for downloading pdf file and Setting chromedriver preferences on protractor tests and they didn't give me satisfactory.
Here is a short look at my protractor configuration.
...
'os': 'Windows',
'os_version': '8.1',
'browserName': 'Chrome',
'version': '55',
'chromeOptions': {
args: ['--no-sandbox', '--test-type=browser'],
prefs: {
download: {
'prompt_for_download': false,
'directory_upgrade': true,
'default_directory': '/tmp'
}
}
}
...
And here is my test spec.
it('file download test', () => {
let filePath = path.resolve('/tmp/' + download-filename);
// unlink(filePath);
// click on a link by invoking anchor_element.click()
// at the moment, file download will be done on chrome
// with no prompt experienced
// wait until file has been downloaded,
// (in fact, download can be finished within a sec)
browser.wait(
() => fs.existsSync(filePath),
10000
).then(() => {
// and then expectations here
});
});
So for my case, the files are downloaded successfully but chromeOptions
doesn't seem to work since files are NOT downloaded in the directory given in the 'default_directory'
.
What am I wrong? Or where is the file downloaded with chrome, in my case, and by default?
I am using BrowserStack for selenium server and running local test.
And I am configuring protractor with multiple capabilities by using getMultiCapabilities
option.
Hopefully someone will guide me with some key hints.