angularjs protractor guards isPresent and isDisplayed for element not visible

Posted: March 25, 2015 in web
...
    this.clickByCssIfVisible = function (selector) {
        var elem = element(by.css(selector));
        self.wait(elem);
        elem.click();
    };
    this.clickByCssIfVisibleAll = function (selector) {
        var elem = element.all(by.css(selector)).get(1);
        self.wait(elem);
        elem.click();
    };
    this.assertTextByCssIfVisible = function (selector, value) {
        var elem = element(by.css(selector));
        self.wait(elem);
        expect(elem.getText()).toBe(value);
    };
    this.wait = function(elem){
        browser.wait(function () {
            return elem.isPresent();
        });
        browser.wait(function () {
            return elem.isDisplayed();
        });
    };
....
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s