无法阅读财产“等于”#39;未定义的

时间:2018-06-04 13:01:07

标签: protractor cucumber undefined

我使用量角器来测试我的应用。

我试图在<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();
    });
});

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

我使用以下方法解决了这个问题:

K

谢谢你一样;)