javascript - Cannot return string from value of element in protractor test -


so i'm trying string value returned value of element on resolution of promise. want pass raw string value function i'm building inside protractor test.

this element:

<div style='hidden' >     <input id="group-sendgrid-hidden-input" ng-model='groupcode' value='dangyo' > </div> 

i'm looking way @ either model value or attribute value (either work). model value might better.

this attempt resolve promise here , return result:

// first element driver object var groupcode = element(by.id('group-sendgrid-hidden-input'));  // next resolve promise provided element groupcode.getattribute('value').then(function(value){      console.log( 'should string: ' + value);      return value; }); 

here console.log( 'should string: ' + value); returns null value , nothing can seems resolve this. i'm sure i'm doing wrong because new protractor , seems simple. else experience behavior?

it's big comment , still guess, how making custom "expected condition" , wait input element's value attribute value not null:

var hasnotnullvalue = function(elementfinder) {     return function() {         return elementfinder.getattribute("value").then(function(value) {             return !!value;  // not null         });     };  };  var groupcode = element(by.id('group-sendgrid-hidden-input')); browser.wait(hasnotnullvalue(groupcode), 10000);  groupcode.getattribute('value').then(function(value){     console.log('should string: ' + value); }); 

you can use evaluate() retrieve model value:

groupcode.evaluate('groupcode').then(function(value) {     console.log(value); }); 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -