5

I'm doing e2e-testing with Protractor and Jasmine. Our application is in Angular.

I have written given getPageTimeout: 500000, allScriptsTimeout: 600000, in the config file. Added defaultTimeoutInterval:500000 as per GitHub .

Even then I'm getting the below exception. Appreciate any help.


A Jasmine spec timed out. Resetting the WebDriver Control Flow.
The last active task was:
Protractor.waitForAngular()
at [object Object].webdriver.WebDriver.schedule (C:\Users\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:345:15)
at [object Object].Protractor.executeAsyncScript_ (C:\Users\AppData\Roaming\npm\node_modules\protractor\lib\protractor.js:1141:26)
at [object Object].Protractor.waitForAngular (C:\Users\AppData\Roaming\npm\node_modules\protractor\lib\protractor.js:1159:15)
at [object Object].getWebElements (C:\Users\AppData\Roaming\npm\node_modules\protractor\lib\protractor.js:191:21)
at [object Object].getWebElements 

7 Answers 7

7

Angular is never becoming ready in your app. The only reason why you're seeing jasmine timeout instead of protractor timeouts is because you increased your protractor timeout limit to be higher than your jasmine timeout limit. This is likely a problem with the app polling indefinitely, rather than a problem with how you're writing your test.

From https://github.com/angular/protractor/blob/master/docs/timeouts.md:

"Before performing any action, Protractor asks Angular to wait until the page is synchronized. This means that all timeouts and http requests are finished. If your application continuously polls $timeout or $http, it will never be registered as completely loaded. You should use the $interval service (interval.js) for anything that polls continuously (introduced in Angular 1.2rc3)."

Sign up to request clarification or add additional context in comments.

4 Comments

Perfect, it worked as excepted, changed timeout to $interval. Thanks alot
Hi mrr, I too facing the same issue... Can you pls tell how to set the timeout to $interval ??
would be happy to know this too, I couldn't find the solution to his, maybe doc changed?
@Bhawani : how did you change timeout to $interval. ? i'm facing the same issue !
3

For people running in this issue only when using Internet Explorer as test browser try to force a new clean session every test:

protractor-conf.js

{"browserName": "internet explorer",
    "ie.forceCreateProcessApi": true,
    "ie.browserCommandLineSwitches": "-private",
    "ie.ensureCleanSession": "true",
    "seleniumAddress": 'http://10.0.1.XXX:4444/wd/hub'
}

Ensure that TabProcGrowth" = dword: 00000000 in Path HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main is set.

Comments

3

Set in your config file eg:

exports.config = {
   seleniumAddress: 'http://localhost:4444/wd/hub',
   suites: require('./Suites.js'),

   capabilities: {
      browserName: 'chrome'
   },

   jasmineNodeOpts: {
     showColors: true,
     defaultTimeoutInterval: 360000
   },

   allScriptsTimeout: 360000, 
};

2 Comments

you should add some explanation to your answer... in this state it's not really helpful
I eddited the post for example of config file parameters. Important is: allScriptsTimeout, and defaultTimeoutInterval (for jasmineNodeOpts), those numbers could be but don't have to be the same.
2

Try this:

describe('Something', function()
{

  it('should do something', function() {
  },500000);

},500000);

Comments

1

Try adding below timeoutinterval in config file

  jasmineNodeOpts: {
    defaultTimeoutInterval: 360000
  }

1 Comment

Shall we add browser.quit(); or browser.close(); to avoid jasmine default time out async error?
0

Try adding below code, jasmine default time 5 sec. The below code will wait for all test cases to complete it task & working fine for me. jasmine.getEnv().defaultTimeoutInterval =15000;

onPrepare: function(){
jasmine.getEnv().defaultTimeoutInterval =your time to set in milli second;
}

Comments

0

For Angular2+ a quick answer here to shorten your research.
Instead of things like setInterval(() => {}, 20000); just use this:

    this.ngZone.runOutsideAngular(() => {
        setInterval(() => {
            this.ngZone.run(() => {
                // whatever you want to do from time to time
            });
        }, 20000);
    });    

you can add ngZone as any other service in constructor, like this:
private ngZone: NgZone,

Make sure you have reviewed all component's chain starting from app-root (AppComponent.ts) and also including custom services. Timer that been set anywhere can cause this issues.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.