0

Using Protractor to run automation cases in Firefox and Chrome.

Chrome does not ask for popup by default but firefox does.So i had to add extra lines for FF.Below is the code. But it is not working. The file am downloading is an excel but i could see the content type as 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' in the dev window.Is that right? should i change it so something else?I tried Download file on Firefox with protractor but it threw AssertionError: WebDriverError: Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'.So I'm using below approach to download to download folder which does not throw an error but still not working as expected

let profile = require('firefox-profile');        
let firefoxProfile = new profile();

// _browser = 'chrome';
_browser = 'firefox';


firefoxProfile.setPreference("browser.download.folderList", 2);
firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk",'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');

exports.config = {
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
    'browserName': _browser,
    'shardTestFiles': false,
    'maxInstances': 1,       
    'acceptInsecureCerts': true,
    'moz:firefoxOptions': {
        'args': ['--safe-mode'],
        'profile': firefoxProfile
    }
},
Nalu
  • 195
  • 2
  • 13
  • 1
    please try setting the Preferences `browser.download.manager.showAlertOnComplete=False` and `browser.download.manager.showWhenStarting=False` – eLRuLL Dec 13 '17 at 20:32
  • 1
    I tried but same behaviour.firefoxProfile.setPreference("browser.download.folderList", 2); firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", 'application/pdf, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); firefoxProfile.setPreference('browser.download.manager.showAlertOnComplete', false) firefoxProfile.setPreference('browser.download.manager.showWhenStarting', false) – Nalu Dec 13 '17 at 22:54
  • 1
    I would be better if you update your question with this information, this isn't readable. – eLRuLL Dec 13 '17 at 22:56
  • i tried your answer , but it is not working.By default the values for these 2 preferences are set to false. – Nalu Dec 13 '17 at 23:17
  • I just tried firefoxProfile.setPreference('browser.download.dir', "C:\\QAAutomation"); When Save as popup came,i manually selected "save to" and then OK. It should get downloaded in C:\QAAautomation.But it is downloading in downloads folder. So I guess the profile is not yet linked to the automation browser. – Nalu Dec 13 '17 at 23:50

0 Answers0