Reputation: 47
View Source:
<div class="well tile single-tile">
<thread></thread>
<table class="table table-hover table-striped table-clickable">
<tbody>
<tr>
<th>Make</th>
<th>Model</th>
<th>Color</th>
<th>Doors</th>
<th>MPG</th>
</tr>
</tbody>
<tbody>
<!-- ng-repeat: car in cars -->
<tr ng-repeat="car in cars" ng-click="car result" class="ng-scope">
<td class="ng-binding">Toyota</td><!--{{car.Make}} -->
<td class="ng-binding">Corolla</td><!--{{car.Model}} -->
<td class="ng-binding">White</td>
<td class="ng-binding">4</td>
<td class="ng-binding">21</td><!--{{car.MPG}} -->
</tr>
<tr ng-repeat="car in cars" ng-click="car result" class="ng-scope">
<td class="ng-binding">Toyota</td><!--{{car.Make}} -->
<td class="ng-binding">Camry</td><!--{{car.Model}} -->
<td class="ng-binding">Black</td>
<td class="ng-binding">4</td>
<td class="ng-binding">20</td><!--{{car.MPG}}
</tr>
</tbody>
</table>
Protractor: I was able to print all values in first row using
element.all(by.repeater('car in cars')).first().getText().then(function(text){and console.log(text)
and in console I saw "Toyota Corolla White 4 21" successfully.
But I want to print only the first value from first row and second row which is "Toyota". I tried using first().get(1).getText().then(function(text)
and first('["$index==1"]').getText()
but it's not working. My test is to verify if there is a value other than "Toyota" in first row and second row, it should fail..
Upvotes: 1
Views: 1095
Reputation: 2279
Chain and extend Binding on the item.key locators
element.all(by.repeater('car in cars')).first().element(by.binding('car.Make')).getText();
for all elements
element.all(by.repeater('car in cars')).each(function(element, index) {
element(by.binding('car.Make')).getText().then(function(text) {
console.log(text);
});
}); //there might be a better way to do this
Upvotes: 1