So I've been searching SO (and various other sites) regarding the issue of Protractor not supporting control and manipulation of "save as" dialogs when downloading files.
I've learned that I need to specify download prefs similar to the code snippet below, specifying "default_directory" as an absolute path.
chromeOptions: {
// Get rid of --ignore-certificate yellow warning
args: ['--no-sandbox', '--test-type=browser'],
// Set download path and avoid prompting for download even though
// this is already the default on Chrome but for completeness
prefs: {
download: {
prompt_for_download: false,
default_directory: '/e2e/downloads/',
},
},
},
However, I have 2 problems in one. Firstly, this works fine in my Linux based Protractor environment. I can specify /any/absolute/path/I/want
and then download to that folder without issue, and without a "Save As" dialog appearing. If I try this in my Windows Protractor environment, with say 'default_directory: 'c:\\some\\folder\\'
(where that path exists!) It doesn't work - the dialog appears, and the prompted folder isn't as specified in my conf.js file. I've tried replacing the double backslashes with single (not good!), and even with forward slashes.... No variant of any valid windows path works? What am I getting wrong?
Also, is there any way of specifying 2 sets of chromeOptions
- and have protractor automatically use the appropriate set according to the host OS? Ie, so I can have 2 default_directory values - one Linux, one Windows, without having to continually comment one or the other out at run time?