Reputation: 915
I tried to validate the element using the below format, but unable to execute.
chai declaration in SD:
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
var expect = chai.expect;
chai.use(chaiAsPromised);
Element definition => searchResult : element(by.className('class_name'))
Code => (searchResult.isPresent()).should.equal(true); & error message => "Cannot read property 'equal' of undefined"
Code => expect(searchResult.isPresent()).toBe.equal(true); & error message => "Invalid Chai property: toBe. Did you mean \"to"
Code => expect(searchResult.isPresent()).to.equal(true); & error message => "expected { Object (flow_, stack_, ...) } to equal true"
could anyone help me to find the element.
Upvotes: 0
Views: 830
Reputation: 2375
If you are using CucumberJS + Protractor + Chai + Chai-as-promised you should write you expectation as following
expect(searchResult.isPresent()).to.eventually.equal(true);
You need to add the eventually
because you are working with promisses
Upvotes: 3