Protractor 无法读取属性';相等';未定义的
我正在使用量角器测试我的应用程序 我正在尝试获取标记Protractor 无法读取属性';相等';未定义的,protractor,cucumber,undefined,Protractor,Cucumber,Undefined,我正在使用量角器测试我的应用程序 我正在尝试获取标记中的值,我可以按照控制台.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 a
中的值,我可以按照控制台.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"));
同样感谢你;) 假设您使用的是chai.expect,可以肯定它应该是
expect(text).to.equal('value is error')