in Protractor by
Why getText() method returns Object instead of String in Protractor?

1 Answer

0 votes
by
When using Java, getText() method returns the corresponding text from the element. However in Protractor, getText() method returns Object something like [objectObject] In Protractor, the getText() method returns a Promise. We need to resolve this in order to get the text.

Syntax:

element.getText().then(function (text) {

console.log(text);

});

element.getText().then(function (text) {

console.log(text);

});
...