How to create a condition in protractor for when an element exists or not

前端 未结 4 1399
孤独总比滥情好
孤独总比滥情好 2020-12-05 07:20

I\'m using Protractor JS. And the site is written in Angular JS.

So I have a toggle switch. And I noticed the value in the toggle switch goes from true to false and

4条回答
  •  有刺的猬
    2020-12-05 07:32

    isDisplayed() did not work for me. The API may have been changed. isPresent() is my solution:

        var logoutButton =  element(by.css('[ng-click="log_out()"]'));
        logoutButton.isPresent().then(function(result) {
        if ( result ) {
            logoutButton.click();
        } else {
            //do nothing
        }
        });
    

提交回复
热议问题