I am trying to check the value of three dropdown boxes using BDD and Protractor.
The code related to this is:
checkDropdown: function (value, dropdown) {
let name = element(by.id(dropdown));
console.log(name.getText());
expect(name.getText()).to.equal(value);
},
And the output is:
AssertionError: expected { Object (browser_, then, ...) } to equal 'Apparent Energy'
How can I do to make it works? I thought that getText should retrieves a string instead of an object.
Thanks in advance.
expect(name.getText()).to.eventually.equal(value);
Because you are asserting a promise, just change the code like below to wait for the promise,
checkDropdown: function (value, dropdown) {
element(by.id(dropdown)).then(function(elem){
elem.getText().then(function(text) {
expect(text).to.equal(value);
})
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.