protractor-net icon indicating copy to clipboard operation
protractor-net copied to clipboard

WaitForAngular doesn't seem to work

Open SubjectiveReality opened this issue 8 years ago • 5 comments

Anyone else having issues where explicit wait.Until(ExpectedConditions.blah...) are still needed? I'm using page objects and the PageFactory to initialize elements as in this project's example page object.

I've tried explicitly calling ngDriver.WaitForAngular() before and after element clicks, clears, .Text, .Count, etc. Following is an example that regularly fails due to not waiting sufficiently for ng-animate overlays to be cleared from the browser visibility:

[FindsBy(How = How.Custom, CustomFinderType = typeof(NgByBinding), Using = "p[0].RateDescription")]
private IList<IWebElement> lstRateDescriptions { get; set; }

public IEnumerable<string> ListOfRateDescriptions { get {
      // ngDriver.WaitForAngular();
      wait.Until(ExpectedConditions.ElementToBeClickable(lstRateDescriptions[0]));
      return lstRateDescriptions.Select(r => r.Text); } }

SubjectiveReality avatar Aug 23 '16 22:08 SubjectiveReality

Do you get the same issue when you write a test using the nodejs version of Protractor?

rblatz avatar Sep 01 '16 22:09 rblatz

Hi- I had the same thought, got caught up by other priorities so haven't gone that far, but have found that a possible suspect is the use of ngplus module, which uses a delay and animation, much like is reported somewhere in this issue for nodejs Protractor.

The waiting works beautifully on a different angular app to which I've now applied Protractor for .net, which does NOT use the ngplus module and associated animations. So that may have narrowed it down somewhat and it may be a Protractor thing. I'll update as I discover more, but it may be a while.

SubjectiveReality avatar Sep 02 '16 23:09 SubjectiveReality

If it is the ngplus module maybe you could pass in a dummy module that replaces it using a technique like you see in https://github.com/bbaia/protractor-net/blob/master/examples/Protractor.Samples/MockHttpBackend/MockHttpBackendTests.cs

rblatz avatar Sep 03 '16 00:09 rblatz

Good point @rblatz

See exemple behind to disable the ngAnimate :

    NgModule disableNgAnimateModule = new NgModule("noNgAnimateModule", @"
angular.module('noNgAnimateModule', []).run(['$animate', function($animate) {
    // Disable animations
    $animate.enabled(false);
}]);");
    var ngDriver = new NgWebDriver(driver, disableNgAnimateModule);

bbaia avatar Sep 05 '16 13:09 bbaia

Thanks for the ideas guys... I'm giving it a try, but no luck so far (probably due to my lack of understanding of angular itself). Disabling $animate via @bbaia's suggestion didn't seem to disable enough of ngPlus, unfortunately, as animations still run when executing tests.

Am currently tinkering with that approach but looking at using the instructions to disable ngPlus Overlay at the bottom of the page here.

I'm not quite sure how to transpose any of the options into an NgModule ($http, $resource, nor registering an interceptor). Nothing I've tried thus far is good. Here's the first two I've tried:

       private NgModule disableOverlay()
        {
            NgModule disable = new NgModule("noNgPlusModule", @"
                angular.module('noNgPlusModule', []).run(['$resource', function($resource) {
                    return $resource('.*', {}, {
                        get: {
                            'hideOverlay':true
                            }
                    });
                }]);");
            return disable;
        }


       private NgModule disableNgPlus()
        {
            NgModule disable = new NgModule("noNgPlusModule", @"
                angular.module('noNgPlusModule', []).run(['$http', function($http) {
                    url: 'http://localhost/#/',
                    // Disable ngplus
                    hideOverlay: true,
                }]);");
            return disable;
        }

Neither of those options seems viable, come to think of it, since I want to disable for an entire domain and not specific requests. Any ideas? I think I may have to pursue the interceptor option as described on the ngplus page.

SubjectiveReality avatar Sep 06 '16 18:09 SubjectiveReality