angularjs - getAttribute return unresolved -
i'm trying save attribute of input value variable.
this code:
var slidernumber = element.all(by.model('color.red')).get(1); var firstnum = slidernumber.getattribute('value').then(function(value) { return value; }); //some code changes slidernumber attribute expect(slidernumber.getattribute('value')).toequal(firstnum + 1);
this gives me error this:
expected '184' equal promise::433 ([[promisestatus]]: "pending")1.
i've tried:
var firstnum = function() { return slidernumber.getattribute('value').then(function(value) { return value; }); }
that didn't @ all. how resolve promise?
since .getattribute()
returns promise, invoke callback asynchronously, need put test logic within callback:
var slidernumber = element.all(by.model('color.red')).get(1); // initial value slidernumber.getattribute('value').then(function(value) { // once we've got initial value, store it, proceed test var initialvalue = parseint(value, 10); //some code changes slidernumber attribute expect(slidernumber.getattribute('value')).toequal((initialvalue + 1).tostring()); });
you can't return value outside of callback, because callback may or may not called after rest of code.
Comments
Post a Comment