Reputation: 1044
I am trying to test a non-angular page using Protractor.
I am getting one input value of non-angular page with:
console.log(browser.driver.findElement(by.ID('username')).getText());
It's displaying like
[object][object]
I need to get the value of text field. How can i get that?
Upvotes: 0
Views: 662
Reputation: 8167
This is because getText
returns (a promised solved with) text nodes instead of text value.
The result of getText from an input element is always empty
This is a webdriver quirk.
<input>
and<textarea>
elements always have empty getText values. Instead, tryelement.getAttribute('value')
.
form Protractor FAQ
Upvotes: 0
Reputation: 23
The webdriver looks like it should be finding the element correctly, however because of the way the control flow works with protractor you are not able to access the value from a log.
The expect statements normally unravel these responses but you could do something like this if you wanted to see it before that point or modify the value before the expect:
var txArea = browser.driver.findElement(by.ID('username')).getText();
txArea = txArea.then(function(value){
console.log(value);
});
expect(txArea).toEqual('textbox text');
Upvotes: 1