我在基于 Angular 的网站中有一个设置可以打开和关闭下拉菜单.如果它关闭,则它不会显示在主页上.
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.
使用量角器,我需要检查开关关闭时是否不存在此元素.但是,我不应该陷入 Element Not Found Error,因为它是一组测试中的一个.我该怎么做?
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.
这篇关于量角器检查元素是否不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!