Protractor ,Jasmine timeout issue

橙三吉。 提交于 2019-12-21 02:42:06

问题


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 

回答1:


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)."




回答2:


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.




回答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, 
};



回答4:


Try this:

describe('Something', function()
{

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

},500000);



回答5:


Try adding below timeoutinterval in config file

  jasmineNodeOpts: {
    defaultTimeoutInterval: 360000
  }



回答6:


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;
}


来源:https://stackoverflow.com/questions/27972402/protractor-jasmine-timeout-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!