1
votes

I encounter a strange bug with protractor with the following e2e tests:

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

Result:

  ✓ 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

my protractor config:

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

I already tried to increase the multiple timeout available in the protractor config and the use of browser.sleep(n), browser.ignoreSynchronization = true and / or browser.waitForAngularEnabled(false) but nothing works..

Thanks in advance for your time !

2

2 Answers

0
votes

Quite sure that there's a $timeout in Angular env. Ask the Front End developer to have a look over the $timeout and replace it with a $interval.

If your AngularJS application continuously polls $timeout or $http, Protractor will wait indefinitely and time out. You should use the $interval for anything that polls continuously (introduced in Angular 1.2rc3).

0
votes

You need to increase allScriptsTimeout with some higher value. In your case, protractor waited for 11 seconds and it threw an error.