rdazvd
rdazvd

Reputation: 5

angular-phonecat tutorial: protractor.js unexpected behavior under Chrome Canary

I’m setting things up in order to run the angular-phonecat tutorial using Chrome Canary under OS X as a testing browser.

I got everything working, except when I input npm run protractor the e2e test runs on SAFARI of all browsers, despite the fact that I’ve specified Chrome Canary as the browser name in the protractor-conf.js file. Here’s the code:

exports.config = {
  allScriptsTimeout: 11000,

  specs: [
       'e2e/*.js'
 ],

 capabilities: {
   'browserName': 'ChromeCanary',
   'ChromeOptions': {
     'binary': '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'
 }
},

  chromeOnly: false,

  baseUrl: 'http://localhost:8000/',

  framework: 'jasmine',

  jasmineNodeOpts: {
    defaultTimeoutInterval: 30000
  }
};

When I set chromeOnly: true, the test returns an ELIFECYCLE error. I find this very awkward since the same browser name is specified in the Karma configuration file and the unit test runs on Canary as expected. Here’s the karma.conf.js code:

module.exports = function(config){
  config.set({

    basePath : '../',

    files : [
      'app/bower_components/angular/angular.js',
      'app/bower_components/angular-route/angular-route.js',
      'app/bower_components/angular-resource/angular-resource.js',
      'app/bower_components/angular-animate/angular-animate.js',
      'app/bower_components/angular-mocks/angular-mocks.js',
      'app/js/**/*.js',
      'test/unit/**/*.js'
    ],

    autoWatch : true,

    frameworks: ['jasmine'],

    browsers : ['ChromeCanary'],

    plugins : [
            'karma-chrome-launcher',
            'karma-firefox-launcher',
            'karma-jasmine'
            ],

    junitReporter : {
      outputFile: 'test_out/unit.xml',
      suite: 'unit'
    }

  });
};

Two questions:

  1. What could be causing this behavior?
  2. What else could I tinker with to get the e2e test to run on Canary?

Upvotes: 0

Views: 482

Answers (1)

Glenn Attridge
Glenn Attridge

Reputation: 58

I was able to get this working with Chrome Canary by simply reusing the Chrome browserName but providing an alternate binary path. Here's the snippet that will work for your example above.

capabilities: {
    'browserName': 'Chrome',
    'ChromeOptions': {
      'binary': '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'
    }

Probably easier to abstract this into a separate browsers.js file so you can use both canary and chrome like this.

exports.chrome = {
  name: 'Chrome',
  browserName: 'chrome',
  chromeOptions: {
    'args': [
      'incognito',
      'disable-extensions',
      'start-maximized',
      'enable-crash-reporter-for-testing'
    ]
  }
};

exports.chromeCanary = {
  name: 'ChromeCanary',
  browserName: 'chrome',
  chromeOptions: {
    'binary': 'C:/Users/gattridg/AppData/Local/Google/Chrome SxS/Application/chrome.exe',
    'args': [
      'incognito',
      'disable-extensions',
      'start-maximized',
      'enable-crash-reporter-for-testing'
    ]
  }
};

Then in your protractor.conf.js

  var browsers = require('./browsers'),

    multiCapabilities: [
      browsers.chrome
      browsers.chromeCanary

    ],

Upvotes: 3

Related Questions