I've got a fairly simple Protractor test which should check the text value in a row of a ng-repeat.
Here's my HTML:
<div ng-repeat="destination in destinations">
<span>{{destination.city}}, {{destination.country}}</span>
</div>
And here's my JS:
lastDestination = element.all(by.repeater('destination in destinations').row(1));
expect(lastDestination.getText()).toEqual("Madrid, Spain");
The documentation for getText() states:
Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace.
So I'd expect the text from the row's span tag to be returned, but when running the Protractor test, I get the following error for the assertion:
Expected [ 'Madrid, Spain' ] to equal 'Madrid, Spain'.
GetText() seems to be returning an array instead of a string.
I tried resolving getText()'s promised, but still got the same error:
lastDestination = element.all(by.repeater('destination in destinations').row(1));
lastDestination.getText().then(function (text) {
expect(text).toEqual("Madrid, Spain");
});
I can get around the issue by targeting the first value in the array:
expect(text[0]).toEqual("Madrid, Spain");
But I'd still like to know why this isn't working in the first place.
Any ideas?
Update: A similar bug has been reported on Protractor's Github page, so it could be that the getText() function is just not working as it should.