2016-09-20 33 views
1

我試圖實現通過by.repeater與UI網端到端評估行屬性的搜索。量角器按行物業搜索使用by.repeater和評估

這個想法是將來自by.repeater的結果映射到一個新的對象,其中包含從評估和行獲得的底層對象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;     
     }); 
    });  

當我使用或返回行對象時,map函數似乎掛起。根據這https://github.com/angular/protractor/issues/392: Add map() function to element.all它應該工作,但它不。任何想法?

謝謝, David。

回答

1

您可以直接使用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()