Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Angular dependency to be removed #2460

Closed
opichals opened this issue Aug 31, 2015 · 5 comments
Closed

Angular dependency to be removed #2460

opichals opened this issue Aug 31, 2015 · 5 comments

Comments

@opichals
Copy link

As Protractor is not meant to be used exclusively with Angular it would be nice to avoid any 'Angular' dependency and rather let angular implement a Protractor API to become properly Protractor testable and utilize the waitStable testability feature.

We have been successfully using Protractor to test a ReactJS application which implements the necessary stuff from the window.angular for Protractor to work. The following code is the one that works and simulates the whenStable() functionality:

window.angular = {
    // dummy for Protractor boot
    resumeBootstrap: function() {},

    // dummy for Protractor boot
    module: function() {
        var module = {
            config: function() {
                return module;
            }
        }
        return module;
    },

    // hook for `github.com/angular/protractor/lib/clientsidescripts.js: waitForAngular`
    getTestability: function() {
        return {
            whenStable: function(fn) {
                ...
            }
        }
    }
};

The Protractor specific API could look something like (not completely accurate but should be enough to get what I mean):

window.protractor = {
    // ...
    resumeBootstrap: function() {},

    // Simplified config to avoid any proractor -> angular dependency
    config: function(opts) {
    },

    getTestability: function() {
        return {
            whenStable: function(fn) {
                ...
            }
        }
    }
}
@stalniy
Copy link
Contributor

stalniy commented Sep 24, 2015

Probably better idea is to implement an ability to create Framework/App specific waiter.

var react = {
   connect: function() {
      // here is dance with angular.resumeBootstrap and similar stuff
   },

   wait: ..., // similar to waitForAngular implementation here

   addMockModule: ....

   removeMockModule: ....
};

PROS:

  • no extra global variable in app scope
  • no need to change app
  • clear interface
  • can be created for any framework/app on Nodejs side

And by default use waiter for angular.js, first one and last 2 methods are optional

@juliemr
Copy link
Member

juliemr commented Oct 7, 2015

The way that we'd like to implement this is with a separate process that proxies commands to webdriver. Then, that process will take care of all waiting commands, and will have the option to swap them out. I think this will clean up a lot of things in Protractor both with Angular apps and in general.

This is on our timeline for end of 2015.

@opichals
Copy link
Author

@stalniy @juliemr Could you please elaborate on your ideas of the framework specific waiter API and the separate process workflow and API?

It would be clean for the protractor core not to contain any angular specific waiting and be generic in API terms.

@caseyhoward
Copy link

It would also be nice to use protractor's angular logic in other selenium wrappers. For example, I work on QA scripts in both ruby and scala that are now hitting pages with angular. I'm not sure if this means moving the code in https://github.com/angular/protractor/blob/master/lib/clientsidescripts.js and writing your own code that calls the functions in that file. I just don't want to write my own code that waits for angular when I know that it already exists.

@juliemr
Copy link
Member

juliemr commented Jul 14, 2016

I'm closing this issue in favor of #3375 and #3374.

Note that our primary use case is to support Angular apps.

@juliemr juliemr closed this as completed Jul 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants