27

I've been experiencing the intermittent timeouts that are blamed in the Protractor FAQ on use of $timeout for polling (AKA: The waitForAngular timeout). I wonder if it fails also in the cases its not polling. For my team it comes more to light as we rely on the Angular Material components. They are heavy on animation interactions with constant use of $timeout(func, 0). This question is similar to issue #29966301, but focuses on a possible issue between Angular Material and Protractor. I'm really interested to know how folks that heavily utilize Angular Material and Protractor deal with such issues if they encounter them at all.

The interesting point is that I have not seen neither in the Protractor nor Angular Material github sites any utilization of each others capabilities. Since both of them are Angular libraries coming from the same group in Google, @juliemr and the Protractor Gang can talk with @ThomasBurleson and the Material group to come up with comprehensive use cases and E2E tests for Angular Material using Protractor to flush out these issues.

Community
  • 1
  • 1
Gabriel Kohen
  • 4,166
  • 4
  • 31
  • 46
  • Not exactly and answer, but when it comes to animations, I've succesfully used explicit waits with expected conditions (http://stackoverflow.com/a/29151849/771848). – alecxe May 01 '15 at 17:59
  • I actually did start using EC all over. It did reduce the occurrence of such issues but they still happen intermittently. – Gabriel Kohen May 01 '15 at 18:14
  • Can you provide a concrete example? (A snippet of the HTML and of the test that is running into problems?) – P.T. May 05 '15 at 17:04
  • One time that it happens more than others is when using the Angular Material with the $mdDialog service. You want to check at a certain point that the dialog has closed. On our CI machine which runs Ubuntu with XVFB it will fail about a third of the time. On my Windows machine it might fail in 1 our of 10 cases - intermittently. – Gabriel Kohen May 05 '15 at 18:27
  • @GabrielKohen - did you ever find a way forward with your e2e testing of your angular material based application? We too are facing intermittent test failures on our CI server, without any real pattern. We have disabled animations also. – mindparse Mar 18 '17 at 08:32
  • @mindparse, we utilized a logic that will retry a test up to n times to overcome such brittleness. – Gabriel Kohen Mar 18 '17 at 12:30

2 Answers2

1

Well protractor is designed to test angular, so if you are using waitForAngular function and your website is angular you should not use that, you should do the following beforeEach test:

browser.ignoreSynchronization = false;

and you can do this to make your tests faster and probably help removing the timeout problem, on your protractor-conf.js file add this code:

...

onPrepare: function() {
    var disableNgAnimate = function () {
        angular.module('disableNgAnimate', []).run(function($animate){
            $animate.enabled(false);
        });    
    },
    browser.addMockModule('disableNgAnimate', disableNgAnimate);
},

...

and maybe you should check this video out.

atfornes
  • 468
  • 5
  • 21
Pedro Silva
  • 263
  • 2
  • 17
  • 1
    ignoreSynchronization seems to massively mess up the tests as it would seem like its the way the Protractor team intended it to be used. I've disabled the animations and still the test sporadically fail waiting on Angular. It happens whether I'm running it in direct connection or through Selenium. – Gabriel Kohen Jun 08 '15 at 15:29
1

I would add that disabling ngAnimate may not be enough. You may also have to disable Angular Material's CSS animation by injecting CSS inside the protractor 'onPrepare' option. (How to disable animations in protractor for angular js application).

Community
  • 1
  • 1
dhwang
  • 57
  • 8