Failed: Timed out waiting for asynchronous Angular

2019-04-18 20:12发布

I would like to end-to-end test our angular 2 application using Protractor, but I'm stuck with the message:

"Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds."

My conf file.

exports.config = {
  directConnect: true,
  specs: ['spec.js'],

  // For angular2 tests
  useAllAngular2AppRoots: true,
}

Chrome is opened, and the website is also opened, then nothing happens till the the timeout.

When disabling the synchronisation (using browser.ignoreSynchronization = true; ), it's OK. But I'm loosing the "automatic waiting" feature, one of the main advantages of using Protractor.

The application is fully based on angular 2. So why this does not work?

Our developers told me that we are not polling (one of the possible cause according Protractor documentation). By the way, we are using websocket architecture. I don't know if there's a link.

Actually, I don't know how to troubleshoot this issue at all.

Could someone help, please?

3条回答
神经病院院长
2楼-- · 2019-04-18 20:51

Temporarily enabling browser.ignoreSynchronization fixes it, as reported in an answer here.

browser.ignoreSynchronization = true;

(code that throws the error)

browser.ignoreSynchronization = false;
查看更多
狗以群分
3楼-- · 2019-04-18 21:05

Your guess is right. This error would occur when their are any outstanding tasks running in your angular2 application.

Yes, the most common reason is when application continuously polls $timeout or $http, Protractor will wait indefinitely and time out. But this can also occur in scenarios where App takes more than 11 seconds

Please refer here for more information on different timeouts

the default timeout value is 11 seconds. You can change this by adjusting the below value in config.js and try and see if you are still seeing the issue

  /**
   * The timeout in milliseconds for each script run on the browser. This
   * should be longer than the maximum time your application needs to
   * stabilize between tasks.
   */
  allScriptsTimeout?: number;
查看更多
The star\"
4楼-- · 2019-04-18 21:10

Modify the test case and put browser.waitForAngularEnabled(false); after the first click, should work.

However, recommended method can be overriding the default timeout in your conf.js file as allScriptsTimeout: 110000

查看更多
登录 后发表回答