Protractor not finding Angular

2,860 views
Skip to first unread message

Michael Bielski

unread,
Oct 15, 2013, 12:37:06 PM10/15/13
to ang...@googlegroups.com
I feel bad for posting things about Protractor here, but I don't know where else to turn since the people that put out that product don't seem to think it needs any means of user support. I'm trying to get Protractor running and thus far it has been anything but easy. My latest snag is that Protractor simply refuses to find Angular. The ng-app attribute is on the HTML tag and Protractor is configured accordingly. When the page loads Angular loads and run and puts my first partial in place, so I know it is present and running.

config:
exports.config = {
    // The location of the selenium standalone server .jar file.
    seleniumServerJar: 'C:/Dev/PrismWeb/selenium/selenium-server-standalone-2.35.0.jar',

    // The port to start the selenium server on, or null if the server should
    // find its own unused port.
    seleniumPort: null,

    // Chromedriver location is used to help the selenium standalone server
    // find chromedriver. This will be passed to the selenium jar as
    // the system property webdriver.chrome.driver. If null, selenium will
    // attempt to find chromedriver using PATH.
    chromeDriver: 'C:/Dev/PrismWeb/selenium/chromedriver.exe',

    // Additional command line options to pass to selenium. For example,
    // if you need to change the browser timeout, use
    // seleniumArgs: ['-browserTimeout=60'],
    seleniumArgs: [],

    // The address of a running selenium server. If specified, Protractor will
    // connect to an already running instance of selenium. This usually looks like
    // seleniumAddress: 'http://localhost:4444/wd/hub'
    seleniumAddress: null,

    // The timeout for each script run on the browser. This should be longer
    // than the maximum time your application needs to stabilize between tasks.
    allScriptsTimeout: 110000,

    // ----- What tests to run -----
    // Spec patterns are relative to the location of this config.
    specs: [
    'c:/dev/prismweb/test/e2e/*.js'
    ],

    // ----- Capabilities to be passed to the webdriver instance ----
    // For a full list of available capabilities, see
    // and
    capabilities: {
    'browserName': 'chrome'
    },

    // A base URL for your application under test. Calls to protractor.get()
    // with relative paths will be prepended with this.
    baseUrl: 'http://localhost:8080',

    // Selector for the element housing the angular app - this defaults to
    // body, but is necessary if ng-app is on a descendant of <body>
    rootElement: 'html',

    // ----- Options to be passed to minijasminenode -----
    jasmineNodeOpts: {
        // onComplete will be called just before the driver quits.
        onComplete: null,
        // If true, display spec names.
        isVerbose: true,
        // If true, print colors to the terminal.
        showColors: true,
        // If true, include stack traces in failures.
        includeStackTrace: true,
        // Default time to wait in ms before a test fails.
        defaultTimeoutInterval: 30000
    }
};

test that fails (only test I have right now)
describe('homepage loads: ', function(){
    var ptor;

    it('should load the prism homepage: ', function(){
        ptor = protractor.getInstance();

        beforeEach(function(){
            ptor.get('/');
        });

        var usernameField = ptor.findElement(protractor.By.id("username"));
        //expect(usernameField).toBeDefined();
    });
});

Error output:
UnknownError: javascript error: angular is not defined
  (Session info: chrome=30.0.1599.69)
  (Driver info: chromedriver=2.2,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 19 milliseconds
Build info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12 15:42:01'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_21'
Session ID: c93ded5975147b290017661c82b4eb98
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={chromedriverVersion=2.2}, rotatable=false, locationContextEnabled=true, version=30.0.1599.69, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, applicationCacheEnabled=false, takesScreenshot=true}]

Any guesses? I'm flat out stumped.

Mark Volkmann

unread,
Oct 15, 2013, 1:51:07 PM10/15/13
to ang...@googlegroups.com
I'm no expert on Protractor, but I did get it to work and documented what I learned in slides. They are at http://java.ociweb.com/mark/other-presentations/AngularJS-Testing.pdf. Perhaps they will help you. The information on Protractor starts on slide 19.


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.



--
R. Mark Volkmann
Object Computing, Inc.

Michael Bielski

unread,
Oct 15, 2013, 2:01:53 PM10/15/13
to ang...@googlegroups.com
Nice slides, and I do appreciate the effort, but nothing useful for me. I will post whatever the problem was and how to correct it when (if) I find it.

Scott Rice

unread,
Nov 3, 2013, 10:12:24 PM11/3/13
to ang...@googlegroups.com
Thank for these slides on Protractor Mark - the examples you provided were very helpful. Slide 21 was also much appreciated, as I was confused how to actually run the tests. 

With Protractor, how can I include chrome, internet explorer, and phantomjs in the protractor.conf.js at once. Is this possible? With Karma, it's as simple as listing the browser plugins as comma-separated values, but it does not appear that simple with Protractor. Care to shed any light on using multiple browsers at once?

Mark Volkmann

unread,
Nov 4, 2013, 11:10:39 AM11/4/13
to ang...@googlegroups.com
On Sun, Nov 3, 2013 at 9:12 PM, Scott Rice <scott...@gmail.com> wrote:
Thank for these slides on Protractor Mark - the examples you provided were very helpful. Slide 21 was also much appreciated, as I was confused how to actually run the tests.

I'm glad to hear it was helpful!
 
With Protractor, how can I include chrome, internet explorer, and phantomjs in the protractor.conf.js at once. Is this possible? With Karma, it's as simple as listing the browser plugins as comma-separated values, but it does not appear that simple with Protractor. Care to shed any light on using multiple browsers at once?

It appears that you can only specify one browser in protractor.conf.js. So you'd need a separate configuration file for each browser to be tested and then run the protractor command on each of them. See https://github.com/angular/protractor/issues/20.
 

Charlie

unread,
Aug 19, 2014, 6:24:09 PM8/19/14
to ang...@googlegroups.com
Try this conf:
// An example configuration file.
exports.config = {

    // Capabilities to be passed to the webdriver instance.
    multiCapabilities: [
        {
            'browserName': 'phantomjs',
            'phantomjs.binary.path':'./node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/PHANTOMJS'
        },

        /*{
            browserName: 'chrome',
            'chromeOptions': {
                args: [
                    '--test-type',
                    '--no-default-browser-check',
                    '--no-first-run',
                    '--disable-default-apps',
                    '--disable-popup-blocking',
                    '--start-maximized'
                ]
            }
        },
        {
            'browserName': 'safari'
        },
        {
            'browserName': 'firefox'
        }*/
    ],

    // Spec patterns are relative to the current working directly when
    // protractor is called.
    specs: ['test/e2e/spec/admin/**/*.js'],

    baseUrl: 'http://127.0.0.1:9000/',

    seleniumServerJar: './node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-2.40.0.jar',

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000
    }
};

Scott Rice

unread,
Aug 20, 2014, 9:57:52 AM8/20/14
to ang...@googlegroups.com
Thanks for posting this Charlie. We have moved away from Protractor in our testing the past few months. However, I will try this configuration file out (and revisit Protractor in general), and let you know how it goes.


--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/cc8tYtmd9Vk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.

Michael Bielski

unread,
Aug 20, 2014, 10:28:18 AM8/20/14
to ang...@googlegroups.com
As a brief follow-up to my OP which has been since hi-jacked, we let Protractor sit and age for a while, and like a good wine it only got better. We picked it up last week and everything is going very well now. It worked right out of the box for us and the addition of page objects is the icing on the cake.
Reply all
Reply to author
Forward
0 new messages