Search code examples
protractorangular-ui-gridui-grid

Protractor Search by row property using by.repeater and evaluate


I'm trying to implement a search by row property using by.repeater and evaluate for e2e with ui-grid.

The idea is to map the result from by.repeater to an new object with the underneath object id I get from evaluate and the row so that I can do a filter by id on the new array of objects. Something like this:

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;                   
        });  
    });    

The map function seems to hang when I use or return the row object. According to this https://github.com/angular/protractor/issues/392: Add map() function to element.all it should work but it doesn't. Any idea?

Thanks, David.


Solution

  • You can directly use filter() method to filter the rows based on any condition. look at below example.

    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()