0

i have a input field where I send an input value:

var firstNumber = element(by.model('first'));    
firstNumber.sendKeys(1);

I want to write the value of input box ('1') on console. When I use following:

console.log("Value from input box is: " + firstNumber.getAttribute('value'));

I get following answer:

Value from input box is: [object Object]

How can I get the actual value.

p.s. This may seem very silly question, but I'm absolutely new to javascript, which I'm using in protractor End to end testing using Jasmine framework.

UzIT
  • 51
  • 1
  • 7

1 Answers1

0

firstNumber.getAttribute('value') does not return an actual attribute value but rather it returns a promise, which has [object Object] string representation (documentation reference).

You need to resolve the promise to access the actual value:

firstNumber.getAttribute('value').then(function (value) {
    console.log("Value from input box is: " + value);
});
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195