我在基于 Angular 网站中有一个设置可以打开和关闭下拉菜单。如果关闭,则不会显示在主页上。
使用 Protractor ,我需要检查开关关闭时该元素是否不存在。但是,我不应该陷入“未找到元素”错误,因为它是一组许多测试中的一个。我该怎么做?
我尝试过:
expect($$('.switch').count()).to.equal(0).and.notify(next);
但是我遇到了断言错误...
最佳答案
另一个对我来说效果更好的选项,使用 Protractor “方式”做事 http://angular.github.io/protractor/#/api?view=ElementArrayFinder.prototype.all
element.all(by.css('.k-loading-image')).then(function(items) {
expect(items.length).toBe(0);
});
(我想检查加载指示器是否消失)
关于javascript - Protractor 检查元素是否不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25314019/