Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

mixing angular/non angular pages #89

Closed
lnu opened this issue Sep 13, 2013 · 3 comments
Closed

mixing angular/non angular pages #89

lnu opened this issue Sep 13, 2013 · 3 comments

Comments

@lnu
Copy link

lnu commented Sep 13, 2013

Hello,

I'm stuck: my application is hosted inside an asp.net mvc web site. Everything is done in angular except login/logout, handled by asp.net authentication.
I can log in but when I go to an angular page, it hangs on this:

08:53:00.080 INFO - Executing: [execute async script: return (function () {
var el = document.querySelector(arguments[0]);
var callback = arguments[1];
angular.element(el).injector().get('$browser').
notifyWhenNoOutstandingRequests(callback);
}).apply(null, arguments);, [div#data-ng-app]] at URL: /session/b06710f2-0c8c-40
83-acea-1cf6f0114dfa/execute_async)

My ng-app is also set on a div and configured with the rootElement('div#data-ng-app') in the configuration.

here is my test:

var util = require('util');
describe("security", function () {
    describe('login', function () {

        var ptor = protractor.getInstance();
        var driver = ptor.driver;

        var findByName = function (name) {
            return driver.findElement(protractor.By.name(name));
        };

        driver.get('http://localhost/ecdt/');
        findByName('UserName').sendKeys('xxx');
        findByName('Password').sendKeys('xxx');
        findByName('logIn').click();

        it('userCreate', function () {
            ptor.get('#/usercreate');
            ptor.findElement(protractor.By.input('firstName')).sendKeys('Julie'); //hangs here
        }, 20000);
    });
});

I can test any angular app but not mine :)

Does anybody have an idea on how to handle that situation?

@stickel
Copy link

stickel commented Sep 17, 2013

First thing I notice is there's not expectation in your test. Try adding an expectation to the userCreate test and see if it still hangs.

Are you using a $timeout on the page to repeatedly make AJAX calls? If so, Protractor won't progress until the $timeout finishes (see #49).

@juliemr
Copy link
Member

juliemr commented Sep 19, 2013

I think you'll need to wrap your setup in a beforeEach() block, or else the asynchronous login might not be waited for.

Of course you probably only want to do login one before all your tests run, not before each.

Really, this should be in a beforeAll (or before.once or something), but Jasmine doesn't support that syntax right now. (It will in 2.0). For now, I'd rely on the fact that it() blocks are executed in order, and make your first it() block do login:

var util = require('util');
describe("security", function () {
    describe('login', function () {

        var ptor = protractor.getInstance();
        var driver = ptor.driver;

        var findByName = function (name) {
            return driver.findElement(protractor.By.name(name));
        };

        it('does beforeAll setup', function() {
          driver.get('http://localhost/ecdt/');
          findByName('UserName').sendKeys('xxx');
          findByName('Password').sendKeys('xxx');
          findByName('logIn').click();
        });

        it('userCreate', function () {
            ptor.get('#/usercreate');
            ptor.findElement(protractor.By.input('firstName')).sendKeys('Julie'); //hangs here
        }, 20000);
    });
});

@juliemr
Copy link
Member

juliemr commented Sep 30, 2013

Now, this can also be done in the onPrepare block in your config file.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants