How to implement intervals/polling in angular2 to work with protractor? How to implement intervals/polling in angular2 to work with protractor? selenium selenium

How to implement intervals/polling in angular2 to work with protractor?


After some investigation, I found two possible solutions:

  1. browser.ignoreSynchronization = true instructs protractor to stop waiting for http calls and interval scripts. However, this will likely make writing e2e tests much harder, because now you have to manually wait for elements and pages to load before testing them.
  2. The protractor-xhr-only plugin basically does the same thing as ignoreSynchronization, but only for interval scripts. Protractor will still wait for $http calls to finish.

Neither of both are a perfect solution, but better than nothing.


https://github.com/angular/protractor/issues/3349#issuecomment-232253059

resolved this problem with help from juliemr:

this.ngZone.runOutsideAngular(() => {  this.timer = Observable.interval(1000)}

run timeout out of zone, then protractor will not wait for it.