You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
Test run fails with :"Failed: Timed out waiting for asynchronous Angular tasks to finish after..." #4584
import { browser, by, element, ExpectedConditions as EC } from 'protractor';
describe('Test to show Protractor vs Angular sync issue', () => {
it('Prime NG growl', () => {
browser.get('https://www.primefaces.org/primeng/#/growl');
expect(element(by.css('.ui-button[label="Warn"]')).isPresent()).toBe(true);
element(by.css('.ui-button[label="Warn"]')).click();
element(by.css('.ui-button[label="Success"]')).click();
});
});
Output from running the test Failed: Timed out waiting for asynchronous Angular tasks to finish after 110 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular While waiting for element with locator - Locator: By(css selector, .ui-button[label="Success"])
Steps to reproduce the bug Just run above test case.
The URL you are running your tests against (if relevant) https://www.primefaces.org/primeng/#/growl
Hi protractor team,
Recently we have faced with blocking issue, synchronisation between Protractor and Angular fails. Please use above test example to reproduce the issue.
If modify the test case and put browser.waitForAngularEnabled(false); after the first click - test passed success. So it looks like Protractor becomes waiting for Angular to complete its tasks infinitely.
Please investigate the issue and help to fix it as it's a really blocker for our team now.
Reacted by TJ Lavelle, Arkadiusz Półgęsek, Andrey Pavlov, João Paulo Siqueira Lins, jscti, Eliran Elnasi, Marl, Maxime Lafarie, carlos, Herc and 10 more
Reacted by Arkadiusz Półgęsek, Eliran Elnasi, Marl and carlos
I have the same issue. The problem is not protractor, it's the growl component from primeng. It uses timeout() so the protractor thinks that the angular is busy and waits until timeout. That's why when you use waitForAngular(false) it works. I didn't find a solution yet too.
Yeah, you can see here, on the initTimeout() method, there is a setTimeout function. You know this is the problem because when you set the "sticky" input to true, the protractor problem goes away, at least in my case.
My workaround for now is set waitForAngular to false and finish my test case this way, then I set it back to true and do a page refresh, resetting the timeout and then we can do the other tests normally.
PrimeNG could add an input to the Growl Component so we could run the timeout outside angular zone, thus resolving the issue, but I don't really know if they are willing to do that.
I really do not believe it's Protractor's fault, technically it's working as intended.
I see this too. I have the following versions installed :
Node Version: v8.9.1
Protractor Version: 5.2.0
Browser(s): Chrome 62.0.3202.89
Operating System and Version Mac OS High Sierra 10.13.1
angular version : 2.3.0
I observed this since last two days when my tests which were passing earlier suddenly started to fail.
My bad , setting browser.waitForAngularEnabled(false) isn't really solving the problem as it is inconsistent and not working every time.
Any better work around till the issue is resolved.
update : My dev team made changes to the application code which made the timeout to run outside angular zone. This made my tests green. But , i strongly believe this needs to be considered by protractor , perhaps.
Yes, I believe, there are some other components expect PrimeNG growl one. That might use timeouts as well. So we have to deal with such cases.
It's better to get some thought about the issue from Protractor's team. As they might be aware of the issue and have some generic approach how to workaround it.
For now, if you have a "Repeated" setTimeout / setInterval in your app, Angular will always waits for your "setTimeout / setInterval " and therefore never stable and Protractor will wait for it forever.
The regular solution is let that kind of "Repeated" setTimeout / setInterval run outside the Angular so that Angular zone won't be aware of that kind of async tasks.
But that solution is not ideal, some third party library has that kind of async call and we cannot change third party library.
Our current plan is to introduce a new mechanism to let Protractor ignore some asynchronous tasks based on some Rules. @heathkit is working on it, but it is involved with lots of changes in Angular and Zone. There's no ETA for that right now.
As mentioned above, this was caused by repeated settimeout/setInterval in the test app.
Just sync with @heathkit His change probably can be checked in at the end of this month, which should be able to let Protractor conditionally ignore some asynchronous tasks.
For now, the recommend way is to let the repeated settimeout/setInterval run outside angular, so that it won't affect the stability of angular.
If you cannot do so, e.g. the repeated settimeout/setInterval comes from a third party library, you have to
disable sync with angular in your test:
browser.waitForAngularEnabled(false)
Reacted by Justin Toth, Sri, Hélio Beirão, Marina and jitendrapanwar
You need to use browser.waitForAngularEnabled(true) before the timeout. this code(browser.waitForAngularEnabled(true)) will wait for pending http requests and timeouts to finish. This worked fine for me, Hope this will work for you guys also.
Hello.
I have the same problem with timeouts on Angular application, which uses primeng = 5.2.5.
Could you please specify in what version of primeng this problem was fixed?
@qiyigg Do you know if the change you mentioned (to let Protractor conditionally ignore some asynchronous tasks) was ever merged in? And if so, is there any documentation or examples for how we might use this feature? We're running into this same problem with libraries besides primeng.
@qiyigg Do you know if the change you mentioned (to let Protractor conditionally ignore some asynchronous tasks) was ever merged in? This is now a problem for everyone using Firebase with Angular & can imagine this will be an issue that will keep coming up.
@JamboBuenna As far as I know, @heathkit task was paused, and mainly because the original implementation relies on some Angular API that we might deprecate soon.
add @vikerman, who will take over the Protractor stuff.
In your update callback, look at the list of tasks and filter out the ones you don't care about. If the update callback returns true, whenStable() will return.
The current implementation of Testability does depend on Zone.js. However, I think you can count on Testability.whenStable() to continue to have knowledge of async tasks, regardless of what, if anything, happens with Zone.js
Reacted by Yuri Katkov, wiedzmin26 and ash-lionell
Activity
joaopslins commentedon Nov 22, 2017
I have the same issue. The problem is not protractor, it's the growl component from primeng. It uses timeout() so the protractor thinks that the angular is busy and waits until timeout. That's why when you use waitForAngular(false) it works. I didn't find a solution yet too.
aozolin commentedon Nov 24, 2017
Thanks jotapsi.
In this case I see 2 probable issues:
joaopslins commentedon Nov 24, 2017
Yeah, you can see here, on the initTimeout() method, there is a setTimeout function. You know this is the problem because when you set the "sticky" input to true, the protractor problem goes away, at least in my case.
My workaround for now is set waitForAngular to false and finish my test case this way, then I set it back to true and do a page refresh, resetting the timeout and then we can do the other tests normally.
PrimeNG could add an input to the Growl Component so we could run the timeout outside angular zone, thus resolving the issue, but I don't really know if they are willing to do that.
I really do not believe it's Protractor's fault, technically it's working as intended.
SrivaniA commentedon Nov 25, 2017
I see this too. I have the following versions installed :
Node Version: v8.9.1
Protractor Version: 5.2.0
Browser(s): Chrome 62.0.3202.89
Operating System and Version Mac OS High Sierra 10.13.1
angular version : 2.3.0
I observed this since last two days when my tests which were passing earlier suddenly started to fail.
My bad , setting browser.waitForAngularEnabled(false) isn't really solving the problem as it is inconsistent and not working every time.
Any better work around till the issue is resolved.
SrivaniA commentedon Nov 27, 2017
update : My dev team made changes to the application code which made the timeout to run outside angular zone. This made my tests green. But , i strongly believe this needs to be considered by protractor , perhaps.
aozolin commentedon Nov 29, 2017
Yes, I believe, there are some other components expect PrimeNG growl one. That might use timeouts as well. So we have to deal with such cases.
It's better to get some thought about the issue from Protractor's team. As they might be aware of the issue and have some generic approach how to workaround it.
qiyigg commentedon Dec 6, 2017
For now, if you have a "Repeated" setTimeout / setInterval in your app, Angular will always waits for your "setTimeout / setInterval " and therefore never stable and Protractor will wait for it forever.
The regular solution is let that kind of "Repeated" setTimeout / setInterval run outside the Angular so that Angular zone won't be aware of that kind of async tasks.
But that solution is not ideal, some third party library has that kind of async call and we cannot change third party library.
Our current plan is to introduce a new mechanism to let Protractor ignore some asynchronous tasks based on some Rules.
@heathkit is working on it, but it is involved with lots of changes in Angular and Zone. There's no ETA for that right now.
shivangsanghi commentedon Feb 17, 2018
I am also facing the same issue in my project.
carlospliego commentedon Mar 7, 2018
Same issue
lxme commentedon Mar 8, 2018
Same issue.
britomarco commentedon Mar 14, 2018
Same issue.
justintoth commentedon Mar 14, 2018
Same issue....
qiyigg commentedon Mar 14, 2018
As mentioned above, this was caused by repeated settimeout/setInterval in the test app.
Just sync with @heathkit His change probably can be checked in at the end of this month, which should be able to let Protractor conditionally ignore some asynchronous tasks.
For now, the recommend way is to let the repeated settimeout/setInterval run outside angular, so that it won't affect the stability of angular.
If you cannot do so, e.g. the repeated settimeout/setInterval comes from a third party library, you have to
disable sync with angular in your test:
browser.waitForAngularEnabled(false)
justintoth commentedon Mar 14, 2018
Thanks, the browser.waitForAngularEnabled(false) worked for me!
adam3039 commentedon Mar 17, 2018
I have the same issue. I have a bit of code running on a Rxjs interval and get this error. If I comment out the interval, all is well.
shivangsanghi commentedon Mar 18, 2018
You need to use
browser.waitForAngularEnabled(true)before the timeout. this code(browser.waitForAngularEnabled(true)) will wait for pending http requests and timeouts to finish. This worked fine for me, Hope this will work for you guys also.mboughaba commentedon Mar 30, 2018
Faced this issue today ✋
In my case, I believe that it is caused by pending http request to angularfire2.
I solved it by adding
aozolin commentedon Apr 25, 2018
Fixed by PrimeNG team.
The issue is being closed.
russelltrafford commentedon May 11, 2018
@aozolin can you confirm in which git commit/issue/release version this is fixed? Perhaps by referencing the fix PR to this issue?
russelltrafford commentedon May 11, 2018
For anyone else wondering, incase they don't reply, I'm assuming they meant fixed in either #4681 or #4681
StanislavKharchenko commentedon May 14, 2018
Hello.
I have the same problem with timeouts on Angular application, which uses primeng = 5.2.5.
Could you please specify in what version of primeng this problem was fixed?
Thank you.
aschlei commentedon May 21, 2018
@qiyigg Do you know if the change you mentioned (to let Protractor conditionally ignore some asynchronous tasks) was ever merged in? And if so, is there any documentation or examples for how we might use this feature? We're running into this same problem with libraries besides primeng.
qiyigg commentedon May 21, 2018
@aschlei Sorry, It hasn't been checked in yet.
For now, you can disable sync with angular in your test:
browser.waitForAngularEnabled(false);
DocsWebApps commentedon Jun 25, 2018
Same problem but this solution worked OK.
browser.waitForAngularEnabled(false);
JamboBuenna commentedon Sep 19, 2018
@qiyigg Do you know if the change you mentioned (to let Protractor conditionally ignore some asynchronous tasks) was ever merged in? This is now a problem for everyone using Firebase with Angular & can imagine this will be an issue that will keep coming up.
qiyigg commentedon Oct 10, 2018
@JamboBuenna As far as I know, @heathkit task was paused, and mainly because the original implementation relies on some Angular API that we might deprecate soon.
add @vikerman, who will take over the Protractor stuff.
heathkit commentedon Oct 11, 2018
We do have a design for this, but I'm no longer working on Protractor and haven't had time to put it together.
Anyone who wants to could make a Protractor plugin using the new Testability API that could selectively ignore tasks. The rough outline would be:
waitForPromisewaitForPromise, callTestability.whenStable()and pass it an update callback (see https://github.com/angular/angular/blob/16c03c0f38491444942fb165f1e8e2c7651d1494/packages/core/src/testability/testability.ts#L191). This callback will be called every time an async task starts or finishes.whenStable()will return.The current implementation of Testability does depend on Zone.js. However, I think you can count on
Testability.whenStable()to continue to have knowledge of async tasks, regardless of what, if anything, happens with Zone.jswiedzmin26 commentedon Jul 16, 2019
@vikerman Can you help with it?
yadimon commentedon Sep 1, 2020
i had the same issue and started to implement a plugin for this.
https://www.npmjs.com/package/protractor-sync-options-plugin
you can already use it to ignore some special async tasks.
need community help to develop it to high quality and probably more protractor/angular versions.