protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Protractor waitforAngular() waits indefinitely and timesout

Open gamecheck80 opened this issue 10 years ago • 11 comments

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');

gamecheck80 avatar Jun 17 '16 13:06 gamecheck80

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?

gamecheck80 avatar Jun 17 '16 14:06 gamecheck80

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! 😄

NickTomlin avatar Jun 30 '16 10:06 NickTomlin

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!

juliemr avatar Jul 01 '16 19:07 juliemr

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.

Harish247 avatar Feb 01 '17 00:02 Harish247

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 avatar Apr 13 '18 00:04 edenworky

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

adamduren avatar Apr 25 '19 04:04 adamduren

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

sennl avatar Sep 20 '19 20:09 sennl

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(() => {

SteversIO avatar Oct 29 '19 14:10 SteversIO

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)');

angmayor avatar Feb 06 '20 08:02 angmayor

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.

canbax avatar Dec 25 '20 13:12 canbax

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

canbax avatar Jan 15 '21 10:01 canbax