Get attribute from table - Protractor

441 views Asked by At

I have a table with multiple TR row, I need to be able to click on <tr> or any child <td> where VALUE is 91, In this example below there are just 2 values, but in a future there can be a 20 of them, and they can be differently sort as well.

Is there a way I can FIND a value from this below and click on that element?

<td class="ultranarrow ng-binding">91</td>

Table HTML:

                       <tbody>
                        <!-- end ngRepeat: row in gridData | filter:gridFilter --><tr ng-click="toggle(row)" ng-repeat="row in gridData | filter:gridFilter" ng-class="{
                                selected: row.selected,
                                selectable: row.selectable,
                                'text-danger': !row.selectable,
                                modified: row.modified
                            }" class="ng-scope selectable">
                            <td class="minimal text-center">
                                <!-- ngIf: row.selectable --><a class="glyphicon glyphicon-ok dehover ng-scope text-disabled" ng-class="'text-' + (row.selected ? 'primary' : 'disabled')" ng-if="row.selectable"></a><!-- end ngIf: row.selectable -->
                            </td>
                            <td class="ultranarrow ng-binding">91</td>
                            <td class="ng-binding">Spoluúčast (dokumentace)</td>
                            <td class="narrow">
                                <!-- ngIf: row.selected -->
                            </td>
                            <td class="ultranarrow ng-binding">KČ</td>
                        </tr><!-- end ngRepeat: row in gridData | filter:gridFilter --><tr ng-click="toggle(row)" ng-repeat="row in gridData | filter:gridFilter" ng-class="{
                                selected: row.selected,
                                selectable: row.selectable,
                                'text-danger': !row.selectable,
                                modified: row.modified
                            }" class="ng-scope selectable">
                            <td class="minimal text-center">
                                <!-- ngIf: row.selectable --><a class="glyphicon glyphicon-ok dehover ng-scope text-disabled" ng-class="'text-' + (row.selected ? 'primary' : 'disabled')" ng-if="row.selectable"></a><!-- end ngIf: row.selectable -->
                            </td>
                            <td class="ultranarrow ng-binding">95</td>
                            <td class="ng-binding">Předcházející poškození (výpočet)</td>
                            <td class="narrow">
                                <!-- ngIf: row.selected -->
                            </td>
                            <td class="ultranarrow ng-binding">KČ</td>
                        </tr><!-- end ngRepeat: row in gridData | filter:gridFilter -->
                    </tbody>
1

There are 1 answers

2
Delian Mitankin On BEST ANSWER

xpath is your friend when you need exact value matching. This should do the trick:

element.all(by.xpath('.//td[.="91" and @class="ultranarrow ng-binding"]')).click();