0
votes

Currently I am having an issue on this e2e Automation tool (protractor) I tried to set a wait element option but I am still getting the following error on it.

Failed: Timed out waiting for asynchronous Angular tasks to finish after 12 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular While waiting for element with locator - Locator: By(css selector, #company-code). The following tasks were pending: - $timeout: function u(){return e.isActivatePage?void t.cancel(s):(s=t(u,o),void i.poll(r).then(function(t){d=t,e.$broadcast("noti-count-updated",d)}))}

Appreciate your comments on solving this. The codeI tried for an negative scenario as follows, Thanks

it('After invalid login it should show an error toast', function () {
    browser.get('https:XXXX.com');
    var EC = protractor.ExpectedConditions;
    browser.wait(EC.visibilityOf($('#company-code')))
        .then(function () {
            browser.waitForAngularEnabled(false);
            browser.driver.findElement(by.id('company-code')).sendKeys('ccXXX');
            browser.driver.findElement(by.id('username')).sendKeys('[email protected]');
            browser.driver.findElement(by.id('password')).sendKeys('wrong password');
            browser.driver.findElement(by.id('signin')).click()

                .then(function () {

                    var EC = protractor.ExpectedConditions;
                    browser.wait(EC.visibilityOf($('.alert-warning')))
                        .then(function () {

                            var myElement = element(by.css('.alert-warning'));
                            expect(myElement.isDisplayed()).toBeTruthy();

                        });
                });
        });
});

});

2
Does your app having any kind of polling which is using $timeout. This may cause the error, try instead with $interval.tyaga001

2 Answers

2
votes

Currently, browser.waitForAngularEnabled(false); will execute only after EC.visibilityOf($('#company-code'). But it should be set up before your test it starts.

You should write browser.waitForAngularEnabled(false); in you protractor.conf.js file in onPrepare() { } block.

If you want to try it in one test you should browser.waitForAngularEnabled(false); as the first line in you it() block. Or you could set it in beforeAll().

Again, I prefer to keep it inside configuration file in the onPrepare() { }

-1
votes

You should add below configuration into conf.js file to resolve the time out issue.

exports.config = {

allScriptsTimeout: 60000,

//Also add jasmine node options.

jasmineNodeOpts: {

    defaultTimeoutInterval: 30000,


},

};

I think above solution will help this.