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

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

问题描述

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

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.

这两种情况都会导致 Jasmine 规范超时.重置 WebDriver 控制流. 跟随 Error: Timeout - 在 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 的函数来避免显式的 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天全站免登陆