Powered By Blogger

Search Here!

Showing posts with label AngularJS Wait for element to come into view. Show all posts
Showing posts with label AngularJS Wait for element to come into view. Show all posts

Wednesday, April 2, 2014

AngularJS Wait for element to come into view !

Wait for element in protrator JS.

helper.js

/**
* Usage: wait(element, label)
* element : It will wait for this element to come into view
* label : just used for the error message
*/
exports.wait = function (element, label) {
    browser.wait(function () {
        return element.isPresent().then(function (state) {
            if (state == true) {
                return element.isDisplayed().then(function (state2) {
                    return state2 == true;
                });
            } else {
                return false;
            }
        });
    }, 10000, label + " did not appear");
    browser.sleep(250);
};


Call This Function

Test.js

this.bookContextMenuIcon = $('.context-info-icon');

helper.wait(this.bookContextMenuIcon, "book context menu icon");