超时问题可以是browser.sleep()和browser.waitForAngular的结果吗? [英] Can the time out issue be the consequence of browser.sleep() and browser.waitForAngular?

查看:783
本文介绍了超时问题可以是browser.sleep()和browser.waitForAngular的结果吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在量角器脚本中,我总是遇到超时问题,即使我把一个大的超时的茉莉花间隔 allscripttimeout ...
在某些地方我不得不等到元素出现在主页中,直到网址完全加载为止。

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.

超时问题可以是


  • browser.sleep(time_ms);

  • 的结果browser.waitForAngular();

如果是这样,我该如何解决这个问题?

If so, how can i fix this problem ?

这里有详细问题

谢谢,

推荐答案

是的,它们可能是 - browser.sleep()只有在睡眠时间超过Jasmine超时间隔(默认为30秒)时才会超时。

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()会自动应用于Protractor的每个webDriver动作,因此您不需要调用它。如果这个时间已经结束,那么你的应用程序仍在同步。

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.

这两个都会导致 A Jasmine规范超时。重置WebDriver控制流。跟随错误:超时 - 在jasmine.DEFAULT_TIMEOUT_INTERVAL指定的超时时间内未调用异步回调。如果耗时太长。

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.

我不肯定你会怎么解决它 - 你有很多关于超时的问题(有充分的理由),但此时我认为你需要使用 browser.ignoreSynchronization = true; 并将您的应用视为非Angular,如果您遇到这么多超时问题。有些事情阻止了同步完成。

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.

通过扩展Protractor的功能,可以在非Angular应用程序上无缝创建和执行几种辅助方法,以避免显式 browser.sleep()的。例如,下面的代码暂停测试执行,直到 isPresent 返回true(或者直到超过 timeout 失败我指定)

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

这篇关于超时问题可以是browser.sleep()和browser.waitForAngular的结果吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆