問題描述
我在基于 Angular 的網(wǎng)站中有一個設(shè)置可以打開和關(guān)閉下拉菜單.如果它關(guān)閉,則它不會顯示在主頁上.
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.
使用量角器,我需要檢查開關(guān)關(guān)閉時是否不存在此元素.但是,我不應(yīng)該陷入 Element Not Found Error,因?yàn)樗且唤M測試中的一個.我該怎么做?
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?
我已經(jīng)嘗試過:
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.
這篇關(guān)于量角器檢查元素是否不存在的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!