量角器 使用 by.repeater 按行 属性 搜索并计算
Protractor Search by row property using by.repeater and evaluate
我正在尝试使用 by.repeater 和 evaluate 按行 属性 搜索 e2e使用 ui-网格。
我的想法是将 by.repeater 的结果映射到一个新对象,该对象具有我从 evaluate 和行中获得的底层对象 id,这样我就可以按 id 对新对象数组进行过滤。像这样:
return this.getGrid( gridId ).all( by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index') ).map(function(row, index){
return {
index: index,
row: row,
id: row.evaluate('row.entity.id')
};
}).then(function(maps){
return maps.find(function(e){
return e.id === rowId;
});
});
当我使用 or return 行对象时,地图函数似乎挂起。根据这个https://github.com/angular/protractor/issues/392: Add map() function to element.all,它应该可以工作,但没有。有什么想法吗?
谢谢,
大卫。
您可以直接使用filter()
方法根据任何条件过滤行。看下面的例子。
return this.getGrid(gridId).all(by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index')).filter(function(row_element){
return row_element.evaluate('row.entity.id').then(function(Current_rowid){
return Current_rowid == rowId;
})
}).first()
我正在尝试使用 by.repeater 和 evaluate 按行 属性 搜索 e2e使用 ui-网格。
我的想法是将 by.repeater 的结果映射到一个新对象,该对象具有我从 evaluate 和行中获得的底层对象 id,这样我就可以按 id 对新对象数组进行过滤。像这样:
return this.getGrid( gridId ).all( by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index') ).map(function(row, index){
return {
index: index,
row: row,
id: row.evaluate('row.entity.id')
};
}).then(function(maps){
return maps.find(function(e){
return e.id === rowId;
});
});
当我使用 or return 行对象时,地图函数似乎挂起。根据这个https://github.com/angular/protractor/issues/392: Add map() function to element.all,它应该可以工作,但没有。有什么想法吗?
谢谢, 大卫。
您可以直接使用filter()
方法根据任何条件过滤行。看下面的例子。
return this.getGrid(gridId).all(by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index')).filter(function(row_element){
return row_element.evaluate('row.entity.id').then(function(Current_rowid){
return Current_rowid == rowId;
})
}).first()