1

I tried to evalaute a angular variable in protractor using "evaluate()" and got the value. How do I verify

element.evaluate('angularObj').then(function(angularObj) {
    expect(angularObj.type).to.equal('myType');     
});

But it says

TypeError: 'kitchen' is not a thenable.

kitchen is the value in angularObj.type

How can i assert the value in protractor?

giri-sh
  • 6,934
  • 2
  • 25
  • 50
AJJ
  • 3,570
  • 7
  • 43
  • 76

2 Answers2

1

.then() is a chaining functionality used whenever a promise is returned by a function in protractor. .evaluate() function returns an ElementFinder and not a value, so it cannot be chained. Here's how to use it -

var ele = element.evaluate('angularObj')
expect(ele.type).to.equal('myType');

Though i haven't tried this, but it should work. Hope it helps.

giri-sh
  • 6,934
  • 2
  • 25
  • 50
0

You better try this alecxe's answer for better solution about evaluate() value.

elm.evaluate("<model of your element>").then(function (value) {
    console.log(value);
});

or

var elm = element(by.model("<model of your element>"));
elm.evaluate("<model of your element> = 'test';");

Hope this helps. :)

Community
  • 1
  • 1
Manuli
  • 1,203
  • 4
  • 20
  • 43