Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WaitForAngular doesn't seem to work #44

Open
SubjectiveReality opened this issue Aug 23, 2016 · 5 comments
Open

WaitForAngular doesn't seem to work #44

SubjectiveReality opened this issue Aug 23, 2016 · 5 comments

Comments

@SubjectiveReality
Copy link

SubjectiveReality commented Aug 23, 2016

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); } }
@rblatz
Copy link

rblatz commented Sep 1, 2016

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

@SubjectiveReality
Copy link
Author

SubjectiveReality commented Sep 2, 2016

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.

@rblatz
Copy link

rblatz commented Sep 3, 2016

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

@bbaia
Copy link
Owner

bbaia commented Sep 5, 2016

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

@SubjectiveReality
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants