Locally my download e2e works fine, my firefox preferences in conf.js correctly disable the browser specific download-popup.
When jenkins runs the test (Jenkins runs on a linux OS, locally I am on macOS), the firefox download-popups aren't disabled.... as the file is never really downloaded.
Also, we are using a custom protracor reporter to make videos of the e2e tests.
See the relevant code below:
conf.js
multiCapabilities: [
{
browserName: 'chrome',
'goog:chromeOptions': {
args: ['--no-sandbox', '--user-data-dir=/tmp']
w3c: false, // problems with latest chrome driver... browser.actions is causing issues: https://github.com/jan-molak/serenity-js/issues/329
prefs: {
download: {
directory_upgrade: true,
prompt_for_download: false,
default_directory: downloadsPath,
},
},
},
},
{
browserName: 'firefox',
marionette: true,
'moz:firefoxOptions': {
args: ['--headless'],
prefs: {
'pdfjs.disabled': true,
'browser.download.folderList': 2,
'browser.download.dir': downloadsPath,
'browser.download.panel.shown': false,
'browser.download.useDownloadDir': true,
'browser.download.manager.useWindow': false,
'browser.helperApps.alwaysAsk.force': false,
'browser.helperApps.neverAsk.openFile': true,
'browser.download.manager.closeWhenDone': false,
'browser.download.manager.alertOnEXEOpen': false,
'browser.download.manager.showWhenStarting': false,
'browser.download.manager.focusWhenStarting': false,
'browser.download.manager.showAlertOnComplete': false,
'browser.helperApps.neverAsk.saveToDisk': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document, '
+ 'application/json, application/vnd.openxmlformats, '
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
},
},
},
],
onPrepare: async () => {
browser.driver.manage().window().setSize(1400, 1200);
browser.waitForAngularEnabled(false);
const caps = await browser.driver.getCapabilities();
// eslint-disable-next-line no-console
console.log('Browser capabilities: %o', caps);
const specReporter = new ProtractorReporter();
jasmine.getEnv().addReporter(specReporter);
},
download-contract.js
const downloadBtn = manipulations.getDomObject('download-contract-button', 'id');
browser.executeScript('arguments[0].click();', downloadBtn.getWebElement());
browser.sleep(5000);
try {
await downloads.verifyFileExists(`mandatierung_${mandateId}.docx`);
const fileSize = await downloads.verifyFileSize(`mandatierung_${mandateId}.docx`);
expect(fileSize).toBeGreaterThan(0);
} catch (err) {
throw new Error(`ERROR: ${err.message}`);
}
downloads.removeFile(`mandatierung_${mandateId}.docx`);
jenkinsfile... this is how the tests are initiated
sh 'protractor-recorder -b=firefox,chrome -r=1400x1280 -p="--suite full" -f=specs/conf.js -o=/tmp/video-out'