Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor Angularjs E2E "browser is not a function"

I keep trying to run some E2E tests out of ToT angular-seed master and keep getting the following error when I run ./scripts/e2e-test.sh:

TypeError: Property 'browser' of object #<Object> is not a function

I get this error when trying to run the following piece of code as one of my e2e scenario:

'use strict';

/* https://github.com/angular/protractor/blob/master/docs/getting-started.md */

describe('MyApp', function() {

  describe(Index', function() {
    beforeEach(function() {
      browser().navigateTo('/');
    });


    it('should render feature specific image', function() {
      expect(element('img.featurette-image').length).toBe('4');
    });
  });
});

I'm wondering if my protractor config is incorrect:

exports.config = {
  allScriptsTimeout: 11000,

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

  capabilities: {
    'browserName': 'chrome'
  },

  baseUrl: 'http://localhost:3000/',

  framework: 'jasmine',

  jasmineNodeOpts: {
    defaultTimeoutInterval: 30000
  }
};

My unit tests are running just fine. This is the Karma config I have for them (note that this is an angular app within the public director of a sinatra application listening on port 3000:

module.exports = function(config){
    config.set({
    basePath : '../',

    files : [
      'https://code.jquery.com/jquery-1.10.2.min.js',
      'app/lib/angular/angular.js',
      'app/lib/angular/angular-*.js',
      'test/lib/angular/angular-mocks.js',
      'app/js/**/*.js',
      'test/unit/**/*.js'
    ],

    exclude : [
      'app/lib/angular/angular-loader.js',
      'app/lib/angular/*.min.js',
      'app/lib/angular/angular-scenario.js'
    ],

    autoWatch : true,

    frameworks: ['jasmine'],

    browsers : ['Chrome'],

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

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

})}

Thanks for the help!

like image 526
sybohy Avatar asked Jul 15 '26 14:07

sybohy


1 Answers

You need to change this line:

browser().navigateTo('/');

to

browser.navigateTo('/');

That's it.

like image 159
Rob Avatar answered Jul 17 '26 18:07

Rob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!