Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Timed out waiting for Protractor to synchronize with the page after 11 seconds

I have a problem with my Protractor tests. My angular app uses $timeout to continuously poll something from a server. Unfortunately this lead to the following error message when I'm running my tests:

 There was a webdriver error: Error Timed out waiting for Protractor to synchronize with the page after 11 seconds. Please see https://github.com/angular/protrac
tor/blob/master/docs/faq.md

How can I handle such continuously polling timeouts? Setting the browser.ignoreSynchronization to false is not a good solution in my case (when I do that I have to insert a lot of browser.sleep())

Switching from $timeout to $interval as suggested here is currently not possible in my application. Increasing the timeout is also not possible (as I said the service is continuously polling something from the server)

Is there a possibility to change the waitForAngular routine so that my test won't timeout?

Any help will be highly appreciated.

like image 952
andreaspfr Avatar asked Mar 05 '15 08:03

andreaspfr


3 Answers

From protractor's documentation:

Before performing any action, Protractor asks Angular to wait until the page is synchronized. This means that all timeouts and http requests are finished. If your application continuously polls $timeout or $http, it will never be registered as completely loaded. You should use the $interval service (interval.js) for anything that polls continuously (introduced in Angular 1.2rc3).

like image 171
Delian Mitankin Avatar answered Oct 21 '22 12:10

Delian Mitankin


Same boat with you.

We've seen a lot of posts discussing sleep(), waitForAngular()and browser.ignoreSynchronization.

I agree with you that it is not a good idea to set: ignoreSynchronization = true, since it forces us to wait on each async process manually.

Some suggested using sleep() and then waitForAngular() together like this:

browser.sleep(10000);
browser.waitForAngular();

I do not really understand why sometimes waitForAngular() fails to wait for the page synchronization to complete, and this "double waiting" code did work.

Please see if it works in your case.

like image 28
Blaise Avatar answered Oct 21 '22 11:10

Blaise


add allScriptsTimeout: 50000 in protractor configuration file

exports.config = {
    ...
    allScriptsTimeout: 50000,
    ...
};

or at least this solved my issue

like image 39
adutu Avatar answered Oct 21 '22 12:10

adutu