Protractor: Disabling flow control generates error: "Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined."

Created on 12 Feb 2019  路  5Comments  路  Source: angular/protractor

Here is my config:

exports.config = {
  capabilities: {
    'browserName': 'chrome'
  },
  seleniumAddress: 'http://localhost:4444/wd/hub',
  framework: 'jasmine',
  specs: ['test.spec.ts'],
  SELENIUM_PROMISE_MANAGER: false,
  jasmineNodeOpts: {
    defaultTimeoutInterval: 30000
  },    
  beforeLaunch: function () {
    require('ts-node/register')
  }
};

And here is my simple test:

import {
    browser,
    ExpectedConditions,
    $
} from 'protractor';

describe('When user click \"Test\" button', async () => {
  beforeAll(async () => {
    expect(browser.getCurrentUrl()).toContain('myawesomewebsite');
  });

  it ("should click the button", async () => {
    var button = $(".button");
    button.click();
  });
});

This throws me the following error:

UnhandledPromiseRejectionWarning: Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined.  This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping.  See http://git.io/v4gXM for details"

However it works great if I set SELENIUM_PROMISE_MANAGER to true.

According to the simplicity of this test, this seems to be a bug with protractor itself, am I wrong?

Most helpful comment

you have to add .waitForAngularEnabled(false) in the onPrepare property of protractor.conf:

onPrepare: async () => {
    await browser.waitForAngularEnabled(false);
    ...
}

All 5 comments

you have to add .waitForAngularEnabled(false) in the onPrepare property of protractor.conf:

onPrepare: async () => {
    await browser.waitForAngularEnabled(false);
    ...
}

@CrispusDH indeed this makes the error go away, but then protractor does not find the Element b/c it does not wait for Angular. Is this supposed to happen ?

You should use explicit waiters before interaction with element. For example before click wait that element is clickable. It might be better to find answer how it implement in Stack Overflow.

you have to add .waitForAngularEnabled(false) in the onPrepare property of protractor.conf:

onPrepare: async () => {
    await browser.waitForAngularEnabled(false);
    ...
}

is that really the intended behavior?
I thought it should be more intuitive to use async/await and more stable.

@Kurt29 is the page per chance Unicode encoded somehow and has the setting in the head?

I'm sitting with the same problem.

Was this page helpful?
0 / 5 - 0 ratings