admin管理员组文章数量:1326036
I am trying to check that an element is present in an angular website. I am using protractor 5.4.0.
In the header of the my_steps.js file I have this:
global.expect = require('chai').expect
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
The code that I am using to assert that the dropdown is present is:
Then(/^(.*) is present$/, function (dropdown,callback) {
expect(element(by.id(dropdown)).isPresent()).toBe(true);
callback();
And the output of the protractor protractor.conf.js mand is:
When application opened # ../Features/step_definitions/my_steps.js:62
✖ Then templateSelection is present # ../Features/step_definitions/my_steps.js:70
Error: Invalid Chai property: toBe. Did you mean "to"?
What am I doing wrong?
Thanks in advance.
I am trying to check that an element is present in an angular website. I am using protractor 5.4.0.
In the header of the my_steps.js file I have this:
global.expect = require('chai').expect
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
The code that I am using to assert that the dropdown is present is:
Then(/^(.*) is present$/, function (dropdown,callback) {
expect(element(by.id(dropdown)).isPresent()).toBe(true);
callback();
And the output of the protractor protractor.conf.js mand is:
When application opened # ../Features/step_definitions/my_steps.js:62
✖ Then templateSelection is present # ../Features/step_definitions/my_steps.js:70
Error: Invalid Chai property: toBe. Did you mean "to"?
What am I doing wrong?
Thanks in advance.
Share Improve this question asked Aug 29, 2018 at 12:47 Alfredo Bazo LopezAlfredo Bazo Lopez 3431 gold badge4 silver badges12 bronze badges2 Answers
Reset to default 2As you are using the 'chai-as-promised' plug-in that extends Chai with a fluent language for asserting facts about promises. You do have to adjust the assertions slightly. The below page gives good examples. Chai as promised page with explanations
For your issue you will need to change:
.isPresent()).toBe(true);
to:
.isPresent()).to.eventually.equal(true);
Therefore your assertion should look like this:
expect(element(by.id(dropdown)).isPresent()).to.eventually.equal(true);
Also note I have not seen the use of .equals
only .equal
isPresent()
returns a promise
expect(element(by.id(dropdown)).isPresent()).to.eventually.equals(true);
本文标签: javascriptError Invalid Chai property toBe Did you mean quottoquotStack Overflow
版权声明:本文标题:javascript - Error: Invalid Chai property: toBe. Did you mean "to"? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742119756a2421641.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论