Protractor e2e test case for downloading pdf file

I can currently set download path location


capabilities: {
    'browserName': 'chrome',
    'platform': 'ANY',
    'version': 'ANY',
    '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/',

For remote testing you would need a more complex infrastructure like setting up a Samba share or network shared directory destination.


var FirefoxProfile = require('firefox-profile');
var q = require('q');

getMultiCapabilities: getFirefoxProfile,
framework: 'jasmine2',

function getFirefoxProfile() {
    "use strict";
    var deferred = q.defer();
    var firefoxProfile = new FirefoxProfile();
    firefoxProfile.setPreference("", 2);
    firefoxProfile.setPreference("", false);
    firefoxProfile.setPreference("", '/tmp');
    firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");

    firefoxProfile.encoded(function(encodedProfile) {
        var multiCapabilities = [{
            browserName: 'firefox',
            firefox_profile : encodedProfile
    return deferred.promise;

Finally and maybe obvious, to trigger the download you click on the download link as you know, e.g.


Leave a Comment