Reputation: 763
I am trying to getText but forever reason it is coming up empty. The text is a readonly field called theater and then a list of 28 numbers underneath it. I have tried many different ways of obtaining the text, including getAttribute which returns null. I have a scroll down function that scrolls down the page so I can see that it is recognized by the selector as it is scrolling and counting. I'm really lost on this one. I have an array called theaterArray that matches the text line by line, however cannot do this.
the html looks like this:
<td class="capacity" title="Theater" data-style="theater">
<input class="readonly" type="text" data-bind="value: capacityObservables.theater, readonly: $root.editItem() !== $data || enhanced, valueUpdate: 'afterkeydown'" readonly="readonly">
</td>
what I have for my code:
//I have tried using the data-bind but i get an invalid selector error
var theaterStyle = element.all(by.css('[data-style="theater"]'));
theaterStyle.count().then(function(count) {
console.log(count);
j = 0;
for (var i = 0; i < count; i++) {
//scrolls down the list element by element
browser.executeScript("arguments[0].scrollIntoView();", theaterStyle.get(i).getWebElement());
theaterStyle.get(i).getText().then(function(text) {
console.log(text, theaterArray[j], j);
expect(text).toEqual(theaterArray[j++]);
});
}
});
Upvotes: 0
Views: 82
Reputation: 14287
Perhaps text is stuffed in the value attribute. Did you try this,
element.all(by.css('td[title="Theater"]>input')).each(function(element, index) {
element.getAttribute('value').then(function (text) {
console.log(index, text);
expect(theaterArray.includes(text)).toEqual(true);
});
});
Upvotes: 1