我想从此表中获取数据“Crab”:
Sushi Roll FishType Taste Level
Cali Roll Crab 2
Philly Tuna 4
Rainbow Variety 6
Tiger Eel 7
下面是检索最后一行数据但我需要从第2行第2列(Crab)获取数据的代码
var rows = element.all(by.repeater('roll in sushi | orderBy:sortType:sortReverse | filter:searchFish'));
//var rows = element.all(by.repeater('alert in alerts'));
var row = rows.last();
var rowElems = row.all(element(by.tagName('td')));
console.log(row.get(0).getText());
下面是外部html
<span ng-show="sortType == 'fish' && !sortReverse" class="fa fa-caret-down ng-hide"></span>
<tr class="ng-scope" ng-repeat="roll in sushi | orderBy:sortType:sortReverse | filter:searchFish">
<td class="ng-binding">Tiger</td>
<td class="ng-binding">Eel</td>
<td class="ng-binding">7</td>
</tr>
答案 0 :(得分:1)
使用.get(index)
index
从0开始:
var rows = element.all(by.repeater('roll in sushi | orderBy:sortType:sortReverse | filter:searchFish'));
var row = rows.get(1);
var rowElems = row.all(element(by.tagName('td')));
console.log(rowElems.get(1).getText());