Protractor Check if Element Does Not Exist(量角器检查元素是否不存在)
问题描述
我在基于 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.
这篇关于量角器检查元素是否不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:量角器检查元素是否不存在


基础教程推荐
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01