【问题标题】:Protractor Angular 4 E2E tests AsyncProtractor Angular 4 E2E 测试异步
【发布时间】:2018-03-20 13:58:49
【问题描述】:

如果不打开同步或告诉它该应用不是 Angular 应用,我无法运行 Angular 4 应用的 E2E 测试

  browser.ignoreSynchronization = true;
  browser.waitForAngularEnabled(false);

当我不执行上述操作时,我收到以下错误:

- Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular

我已经使用这两个命令中的任何一个成功地运行了测试,但是我的超时越来越多,因为我必须使用等待和预期条件才能使页面加载。

【问题讨论】:

  • 角度应用程序可能正在使用超时。 Protractor 不支持这一点,但它会支持间隔,这可以完成同样的事情。在 repo 上查看 this issue 了解更多信息
  • 尝试将此添加到您的配置中:exports.config = { allScriptsTimeout: 11000000, jasmineNodeOpts: { defaultTimeoutInterval: 30000000 }}

标签: angular protractor


【解决方案1】:

上面的解决方案是我让我的代码工作的唯一方法,我没有遇到任何问题。 据我了解 AngularJS 和 Angular 4 的异步是不一样的,量角器是为 AngulaJS 构建的

如果我需要暂停以等待加载我使用的内容:

const EC = protractor.ExpectedConditions;
      browser.wait(EC.presenceOf(foo), 5000, 'error: cant find foo');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多