Daniel Bogart
Daniel Bogart

Reputation: 1295

Protractor test timing out waiting for page sync

My protractor tests are timing out waiting for page sync. I've checked the console, and no errors are shown, so I'm having trouble debugging. I've tried using allScriptsTimeout as well as defaultTimeoutInterval to no avail. No polling in my app, and the test does seem to log in correctly, it just hangs once logged in even though everything looks fully rendered. My code:

Config file:

var exports;
exports.config = {
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',    

// Spec patterns are relative to the location of this config.
specs: [
    'scenarios/features/portfolio-manager-e2e-local.js'
],

multiCapabilities: [
    {
        'browserName': 'chrome'
    }
],

jasmineNodeOpts: {
    onComplete: null,
    isVerbose: true,
    showColors: true,
    includeStackTrace: true,
    defaultTimeoutInterval: 20000,
}
};

Test:

I'll just post one for now, the first test that runs and fails:

it('should login user with correct credentials', function () {
    browser.get('/#/portfolio');
    element(by.model('username')).sendKeys('test');
    element(by.model('password')).sendKeys('test');
    element(by.css('.btn.btn-md.btn-primary')).click();
    expect(element(by.css('.port-header')).getText()).toEqual("Portfolios");
});

Thanks.

Upvotes: 2

Views: 898

Answers (2)

Daniel Bogart
Daniel Bogart

Reputation: 1295

I found an ngToast successful login popup had a timeout of 15.5 seconds which was causing the hangup.

Upvotes: 2

alecxe
alecxe

Reputation: 473763

You need to wait for angular before making any assertions:

Instruct webdriver to wait until Angular has finished rendering and has no outstanding $http calls before continuing.

browser.get('/#/portfolio');
browser.waitForAngular()

Upvotes: 1

Related Questions