Protractor: Protractor waitforAngular() waits indefinitely and timesout

Created on 17 Jun 2016  路  11Comments  路  Source: angular/protractor

Even though the application is angular, when using the protractor function waitForAngular() it waits indefintely.

First i am getting the error "A Jasmine spec timed out. Resetting the WebDriver Control Flow." and then It waits for allScriptsTimeout and then stops. I could see that the element is available in the page, but it is just idle does not do anything. What is the reason, how to fix this?

below is the code:

    element(by.css('[ng-click="gencn(tokForm)"]')).click();
    browser.waitForAngular();

    var paymentuipageelement = element(by.id('method-title'));
    expect(paymentuipageelement.getText()).toEqual('Payment Methods');
needs more info

Most helpful comment

Not sure if this will be helpful to anyone else, but I solved this problem by wrapping browser.get calls like so:

browser.waitForAngularEnabled(true)
await browser.get('http://localhost:8100')
browser.waitForAngularEnabled(false)

All 11 comments

I have added the defaultTimeoutInterval: 100000, now i am only getting "Timed out waiting for Protractor to synchronize with the page".
But surprisingly, the script is executing fine if i move the mouse over the ui (just a slight move is enough). I am not getting any timeout error and working good. But if i do not move my mouse, then it shows the above error. What is the reason for this? How to fix this?

Hi there,

Please follow the Issue Template when opening new issues. Otherwise it's unclear what the issue is and how we can actually help.

Please update your issue with the information from the template; providing a small reproducible example will also help us help you. Thanks! 馃槃

Please see http://www.protractortest.org/#/timeouts for general information on timeouts. Because of the mousemove behavior, I would guess that your page is waiting for a mouse event and then cancelling a $timeout. As Nick said, it's impossible for us to say anything else without a reproducible example. I'm going to close this to keep our issue tracker clean - please open up a new issue if you can create a reproducible example we can run. Thanks!

In case of the problem still there,

I got the same situation while I am using protractor with the angular page. Whenever I load a page and use the browser.waitForAngular() the page used to load forever. In our case fusion charts is the culprit. Since fusion charts are not the angular components whenever waiting for the angular page to load because of the fusion charts it always timed out. The best way to debug this problem is to comment out different sections one at a time and test and see the where you are getting the error.

Not sure if this will be helpful to anyone else, but I solved this problem by wrapping browser.get calls like so:

browser.waitForAngularEnabled(true)
await browser.get('http://localhost:8100')
browser.waitForAngularEnabled(false)

@edenworky no idea why your solution works but thanks! Been looking for a solution for hours.

Why ist there still a workaround as @edenworky suggest needed, the issue is closed, and no one explains why ?

I think the best option is to look at the http://www.protractortest.org/#/timeouts

In particular, your issue is more than likely some async code that runs inside Zone that is long-lived. The section of code dealing with running these async requests outside of Anguar.

The line starting with:
this.ngZone.runOutsideAngular(() => {

I have added the defaultTimeoutInterval: 100000, now i am only getting "Timed out waiting for Protractor to synchronize with the page".
But surprisingly, the script is executing fine if i move the mouse over the ui (just a slight move is enough). I am not getting any timeout error and working good. But if i do not move my mouse, then it shows the above error. What is the reason for this? How to fix this?

R=
I think that in this case is possible that the button or the workflow is not visible unless you do the scroll, something happened to me and I could solve it using: await browser.actions().mouseMove(the-element).perform(); I hope it helps you, in case you don't test a specific element you could also use: await browser.executeScript('window.scrollTo(500,500)');

I have commonJS dependencies. If I don't call browser.waitForAngular(false); tests do not execute. It just waits ALWAYS.

If I set browser.waitForAngular(false);, some tests do not properly wait for the results of HTTP requests. I try to make it wait by using await and async statements but again SOMETIMES it doesn't wait. I couldn't really understand. It would be great if anybody could solve this issue.

I just found the reason. I'm using cytoscape.js. It causes lots of unnecessary change detections. So simply I used runOutsideAngular

this.ngZone.runOutsideAngular(() => {
      this.cy = cytoscape({ /* options here */);
});
Was this page helpful?
0 / 5 - 0 ratings