0

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.

Alfredo Bazo Lopez
  • 323
  • 1
  • 4
  • 12

2 Answers2

1

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);
     })
   });   
}
Santhosh V
  • 380
  • 1
  • 11
0

expect(name.getText()).to.eventually.equal(value);

See here: Getting "is not a thenable" message while using "eventually" in protractor chai

Kacper
  • 1,201
  • 1
  • 9
  • 21