量角器:等待元素变得不可见/隐藏 [英] Protractor : wait for element to become invisible/hidden

查看:110
本文介绍了量角器:等待元素变得不可见/隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到其他与量角器相关的帖子,提到了如何等待某个元素变得可见。但是,最近,我遇到了相反的用例。我想等待一个元素,直到它变得不可见。因为我找不到关于它的任何具体信息。我继续并提出了解决方案。

I saw other protractor related post mentioning about how to wait for an element to become visible. However, recently, I ran into an opposite use case. I wanted to wait for an element until it becomes invisible. Since I could not find anything specific about it. I went ahead and came up with a solution.

var ptor = protractor.getInstance();
    ptor.wait(function() {

        return element(by.css('#my-css-here')).isDisplayed().then(function(isVisible){
            console.log('is visible :' + isVisible);
            return !isVisible;
        });

    }, 12000).then(function(){
        //do whatever you want 
});

希望它会有所帮助。任何建议都值得欢迎。

hopefully it helps. any suggestion is welcome.

谢谢

推荐答案

使用elementexplorer(https://github.com/angular/protractor/blob/master/docs/debugging.md )我看了一下量角器对象,找到了一个对我来说效果很好的答案:

Using the elementexplorer (https://github.com/angular/protractor/blob/master/docs/debugging.md) I looked at the protractor object and found an answer that is working wonderfully for me:

var el = element(by.id('visibleElementId'));
browser.driver.wait(protractor.until.elementIsNotVisible(el));

这篇关于量角器:等待元素变得不可见/隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆