量角器检查元素不存在 [英] Protractor Check if Element Does Not Exist
问题描述
我在我的角度基于网站,打开一个下拉和关闭的设置。如果处于关闭状态,那么它不会显示在主页上。
I have a setting in my angular based website that turns a dropdown on and off. If it is off, then it does not show on the main page.
使用量角器,我需要检查,看看这个元素不是present当开关处于关闭状态。但是,我不应该被扔到元未找到错误,因为它是在一组的一处试验。我应该怎么做呢?
With Protractor, I need to check to see if this element is not present when the switch is off. However, I should not be thrown into Element Not Found Error, as it is one test in a set of many. How should I do this?
我试图做:
expect($$('.switch').count()).to.equal(0).and.notify(next);
不过,我得到一个AssertionError这个...
But I am getting an AssertionError with this...
推荐答案
得到的东西通过我的东西在该文档中找到工作:
Got the thing working by using something I found in the docs:
expect(element(by.css('.switch')).isPresent()).to.become(false).and.notify(next);
还采用断言,所以它不会破坏cucumberjs。
Also uses assertions, so it doesn't break cucumberjs.
这篇关于量角器检查元素不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!