0

I have found this answer however I'm not testing angularjs app but angular 2. Testing AngularJS with Selenium

looking for a similar piece of js code to execute to wait until angular finishes.

I came up with an idea of a decorator that I'll use to wait before touching the app but I don' know what the script would like, I took a look into clientsidescripts.js but I am not an Angular developer and it seems that it gets ng1hooks and testability... so maybe I could extra some bits and pieces and put them into a js file and execute it e.g. like this guy https://github.com/kpodl/pytractor/blob/master/src/pytractor/protractor/extracted/waitForAngular.js but again this is from 2015.

def angular_wait_required(f):

        def wrapped_f(self, *args, **kwargs):
            self.driver.set_script_timeout(30)
            self.driver.execute_async_script(WAIT_FOR_SCRIPT)
            f(self, *args, **kwargs)
        return wrapped_f
1
  • So sweet. did not even give me a chance to edit it and correct typos Commented Jun 29, 2017 at 15:14

1 Answer 1

1
WAIT_FOR_SCRIPT = """
        callback = arguments[arguments.length - 1];
        try {
            var testabilities = window.getAllAngularTestabilities();
            var count = testabilities.length;
            var decrement = function() {
            count--;
            if (count === 0) {
              callback('completed');
                }
            };
            testabilities.forEach(function(testability) {
                testability.whenStable(decrement);
            });
         } catch (err) {
            callback(err.message);
         }
        """

this is what i came up with in the end

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.