【问题标题】:Protractor Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds量角器失败:等待异步 Angular 任务在 11 秒后完成超时
【发布时间】:2017-10-30 16:01:30
【问题描述】:

我从基本量角器测试开始测试页面标题。我正在使用 angular 2.4.10"protractor": "^5.1.2" 当我运行量角器时,出现此错误。

失败:等待异步 Angular 任务在 11 秒后完成时超时。这可能是因为当前页面不是 Angular 应用程序。

这是我的示例代码

//protractor.config.js
exports.config={
seleniumAddress: 'http://localhost:4444/wd/hub',
specs:['index.spec.js'],
capabilities: {
    'browserName': 'chrome',

},
useAllAngular2AppRoots: true,
framework: 'jasmine',

};

//index.spec.js
describe('hello-protractor', function() {
   it('title', function() {

    browser.get('http://localhost:8100/#/');

    var title = element(by.cssContainingText('My Dashboard Title'));
    expect(title.getText()).toEqual('My Dashboard Title');
    expect(title.getAttribute("text")).toEqual('My Dashboard Title');
  });
});

我参考了这个链接来修复https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular

我将此属性设置为allScriptsTimeout:30000,但它显示了**Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL**

【问题讨论】:

    标签: angularjs typescript jasmine protractor


    【解决方案1】:

    根据您提供的信息,您正在测试的页面似乎不包含角度元素,或者需要增加超时时间。

    好的,这是您增加量角器特定超时的解决方案。

    但您也可以覆盖 jasmine 超时。

    尝试将它包含在 config.js 文件中。

    jasmineNodeOpts: {
    isVerbose: true,
    showColors: true,
    defaultTimeoutInterval: 400000
      },
    

    我还看到你提到了框架:jasmine。

    你确定这只是 jasmine 还是 jasmine2?

    如果您使用的是 jasmine2 版本,请将其更改为 framework:'jasmine2'

    Kinldy 让我知道它是否有效。 如果可行,请考虑接受我的回答并投票。

    【讨论】:

    • 嘿..它不起作用。我将框架更改为:'jasmine2'。我在 app.component.ts 和 app-routing.module.ts 中定义了标题,我正在加载另一个组件 forRoot。哪个有http服务调用
    • 我可以要你的 html 的 sn-p 吗?
    • 我也不确定你是否安装了 jasmine 2 版本。你有吗?
    • 我没有安装 jasmine2。我安装了量角器。 import { Component } from '@angular/core'; import { Link } from './frame/model'; @Component({ selector: 'app-root', templateUrl: './app.component.html' }) export class AppComponent { title = 'My Dashboard title';
    • Jasmine 默认和量角器一起安装
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-08
    • 1970-01-01
    • 2017-12-30
    • 2018-09-14
    • 2017-12-18
    • 2017-02-02
    • 1970-01-01
    相关资源
    最近更新 更多