无法使用量角器 Chai 验证元素
Unable to verify the element using protractor Chai
我尝试使用以下格式验证元素,但无法执行。
SD 中的柴声明:
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
var expect = chai.expect;
chai.use(chaiAsPromised);
元素定义=> 搜索结果:元素(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"
谁能帮我找到元素。
如果您使用的是 CucumberJS + Protractor + Chai + Chai-as-promised,您应该按照以下方式写下您的期望
expect(searchResult.isPresent()).to.eventually.equal(true);
您需要添加 eventually
因为您正在使用 promise
我尝试使用以下格式验证元素,但无法执行。
SD 中的柴声明:
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
var expect = chai.expect;
chai.use(chaiAsPromised);
元素定义=> 搜索结果:元素(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"
谁能帮我找到元素。
如果您使用的是 CucumberJS + Protractor + Chai + Chai-as-promised,您应该按照以下方式写下您的期望
expect(searchResult.isPresent()).to.eventually.equal(true);
您需要添加 eventually
因为您正在使用 promise