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

冷暖自知 提交于 2019-12-04 12:39:01

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