protractor - 无法读取未定义的属性“等于”
问题描述
我正在使用量角器来测试我的应用程序。
我正在尝试获取标签内的值<p>
,我可以按照 所示执行此操作console.log
,但预期会返回错误:
[14:54:57] E/launcher - Cannot read property 'equal' of undefined
[14:54:57] E/launcher - TypeError: Cannot read property 'equal' of undefined
这是我的代码stepdefinitions.js
:
Then('I see the alert "Values are incorrect" for the contents which does not match the proper data', function (next) {
browser.sleep(9999);
let failed_msg = element(by.css('.error-message'));
failed_msg.getText().then(function(text){
console.log('MY ALERT MESSAGE FOR THIS SCENARIO IS: ',text);
expect((failed_msg).to.equal("Values are incorrect"));
next();
});
});
有人能帮我吗?
解决方案
我通过使用这个解决了这个问题:
expect(text.should.be.equal("Values are incorrect"));
同样感谢你;)
推荐阅读
- flutter - 调度第一个 bloc 事件或 cubit 方法,在 StatelessWidget 内的页面开始
- python - 如何提取和总结从网站检索到的数字?
- android - 表单提交上的 Django 动态文件输出在移动设备上不起作用
- algorithm - 找到两条线的所有交点
- c - while 循环有终止符号仍然可以正常工作
- python - 如何获取日期输入值?
- google-sheets - 谷歌表格,总结一个公式?
- java - 在 libGDX 中移动玩家时,附加到玩家的 BroadSword 会向前跳 2 个像素
- python - 如何修复 ValueError:分类指标无法处理二进制和连续目标的混合以获得 F1_score
- android - 为什么我的寻呼机适配器不显示任何内容?