0 votes
in Protractor by (19.8k points)
Why getText() method returns Object instead of String in Protractor?

1 Answer

0 votes
by (19.8k points)
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);

});

Related questions

...