Angular 带角度4的量角器5.1.0:两个语句超时,与单个语句相反

Angular 带角度4的量角器5.1.0:两个语句超时,与单个语句相反,angular,protractor,e2e-testing,Angular,Protractor,E2e Testing,我在以下e2e测试中遇到了一个关于量角器的奇怪错误: it('should render vehicle title', () => { expect(vehicleTitle.getText()).toBeTruthy(); }); it('should have color dropdown', () => { expect(colorDropdown.isDisplayed()).toBeTruthy(); }); it('should have title and

我在以下e2e测试中遇到了一个关于量角器的奇怪错误:

it('should render vehicle title', () => {
  expect(vehicleTitle.getText()).toBeTruthy();
});

it('should have color dropdown', () => {
  expect(colorDropdown.isDisplayed()).toBeTruthy();
});

it('should have title and color dropdown', () => {
  expect(vehicleTitle.getText()).toBeTruthy();
  expect(colorDropdown.isDisplayed()).toBeTruthy();
});
结果:

  ✓ should render vehicle title
  ✓ should have color dropdown
  ✗ sould have title and color dropdown
    - 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
    While waiting for element with locator
我的量角器配置:

// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts

/*global jasmine */
const { SpecReporter } = require('jasmine-spec-reporter');
const HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
const reporter = new HtmlScreenshotReporter({
  dest: 'e2e/reporter/screenshots',
  filename: 'protractor-report.html',
  userCss: '../style.css',
  ignoreSkippedSpecs: true,
  reportOnlyFailedSpecs: false,
  captureOnlyFailedSpecs: true
});

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],
  capabilities: {
    browserName: 'chrome',
    chromeOptions: {
      args: [
        'incognito',
        'disable-extensions'
      ]
    }
  },
  directConnect: true,
  baseUrl: 'http://127.0.0.1:9000/',
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
  },
  // Setup the report before any tests start
  beforeLaunch: function() {
    return new Promise(function(resolve){
      reporter.beforeLaunch(resolve);
    });
  },
  afterLaunch: function(exitCode) {
    return new Promise(function(resolve){
      reporter.afterLaunch(resolve.bind(this, exitCode));
    });
  },
  onPrepare() {
    require('ts-node').register({
      project: 'e2e'
    });
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
    jasmine.getEnv().addReporter(reporter);
  }
};
我已经尝试增加量角器配置中可用的多次超时,并使用browser.sleep(n)、browser.ignoreSynchronization=true和/或browser.waitForAngularEnabled(false),但没有任何效果


提前感谢您的时间

非常确定Angular env中有$timeout请前端开发人员查看并用$interval替换它。


如果AngularJS应用程序连续轮询$timeout或$http,则量角器将无限期等待并超时。对于任何连续轮询的对象,都应该使用$interval(在Angular 1.2rc3中引入)。

非常确定Angular env中有$timeout请前端开发人员查看并用$interval替换它。


如果AngularJS应用程序连续轮询$timeout或$http,则量角器将无限期等待并超时。对于任何连续轮询(在Angular 1.2rc3中引入)的对象,都应该使用$interval。

您需要使用更高的值来增加
AllScriptStimOut
。在您的例子中,量角器等待了11秒,它抛出了一个错误。

您需要使用更高的值来增加
allScriptsTimeout
。在您的例子中,量角器等待了11秒,它抛出了一个错误。

我在我的dragrator.conf.js中将allScriptsTimeout更改为120000,现在它抛出“错误:超时-在jasmine指定的超时内未调用异步回调。默认超时\u间隔。”我的jasmineNodeOpts属性中有defaultTimeoutInterval:30000。我在dragrator.conf.js中将allScriptsTimeout更改为120000,现在它抛出“错误:超时-异步回调未在jasmine.DEFAULT\u Timeout\u INTERVAL指定的超时内调用。”我的jasmineNodeOpts属性中有defaultTimeoutInterval:30000。但是我的应用程序是Angular 4应用程序,我已经尝试在我的dragrator.config.js中增加不同的属性,但仍然超时。奇怪的是,前两个测试有效,当我将它们组合在一个测试中时,它超时了。但我的应用程序是Angular 4应用程序,我已经尝试增加我的dragrator.config.js中的不同属性,但它仍然超时。奇怪的是,前两个测试是有效的,当我将它们组合在一个测试中时,它超时了。