Can the time out issue be the consequence of browser.sleep() and browser.waitForAngular?

会有一股神秘感。 提交于 2019-12-09 20:38:20

问题


In protractor scripts i'm always having problem of time out, even if i put a big time out jasmine interval, allscripttimeout... And in some places i'm obliged to wait until element are present like in home page until the url is totally loaded.

Can the time out issue be the consequence of

  • browser.sleep(time_ms);
  • browser.waitForAngular();

If so, how can i fix this problem ?

Here the problem in details

Thanks,


回答1:


Yes they could be -- browser.sleep() would only timeout if you had it sleep longer than your Jasmine timeout interval (default is 30 seconds).

browser.waitForAngular() is automatically applied to every webDriver action by Protractor so you shouldn't need to call it. If this time's out then your app is still synchronizing something.

Both of these would result in A Jasmine spec timed out. Resetting the WebDriver Control Flow. following by Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. if it takes too long.

I'm not positive how you would fix it - you've had a lot of questions about timeouts (for good reason), but at this point I think you need to use browser.ignoreSynchronization = true; and treat your app as non-Angular if you're having this many timeout issues. Something is preventing synchronization from finishing.

There are several helper methods that you can create and execute seamlessly on non-Angular apps by extending Protractor's functions to avoid explicit browser.sleep()'s . For example, the below code pauses test execution until isPresent returns true (or until a failure by exceeding the timeout I specified)

Util.prototype.waitForElementPresent = function (el, time) {
    var timeout = time || 0,

    return browser.wait(function() {
        return el.isPresent();
    }, timeout)
};


来源:https://stackoverflow.com/questions/37161258/can-the-time-out-issue-be-the-consequence-of-browser-sleep-and-browser-waitfor

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