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


基础教程推荐
- Bootstrap 模态出现在背景下 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01