(Protractor) Finding specific row in ng-table by text

0 votes

I am trying to specific element from a table by the second column value. When the element is found, I want to click on it but it doesn't click on it, it just finds the element. ( I have removed the whitespaces that where rendered)

Below is my HTML code:

<table ng-table="tableParams" id="Panel" class="tbl-option-list" template-pagination="directives/controls/Pager/Pager.html">

    <caption translate>Orders</caption>

    <tr id="Panel">

        <!-- 1 -->

        <th class="fixed-width-glyphicon"></th>

        <!-- 2 -->

        <th translate>Identifier</th>

    </tr>

        <tr ng-repeat="item in $data track by $index" ng-class="{'active-bg': order.$selected}" ng-click="changeSelection(order,  getRowActions(order))">

        <!-- 1 -->

        <td class="fixed-width-glyphicon">

            <div class="fixed-width-glyphicon">

                {{item.priority.toUpperCase()[0]}}

            </div>

        </td>

        <!-- 2 -->

        <td>{{item.identifierCode}}</td>

    </tr>

</table>

Below is the select command from protractor:

element.all(by.repeater('item in $data track by $index')).filter(function(row) {

    row.getText().then(function(txt) {

        txt = txt.replace(/\s/g, '');

        var found = txt.split('ID0001');

        return found.length > 1;

    });

}).click();

Actually, protractor is a framework used for angular js based on selenium

May 10, 2018 in Selenium by Martin
• 4,220 points
3,929 views

1 answer to this question.

0 votes

Try this

Return the filtered elements before trying to click on them. Below is the code you can try

element.all(by.repeater('item in $data track by $index')).filter(function(row) {

    return row.getText().then(function(txt) {

        txt = txt.replace(/\s/g, '');

        var found = txt.split('ID0001');

        return found.length > 1;

    });

}).then(function(elem){

    elem[0].click();

});

answered May 10, 2018 by Samarpit
• 5,130 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

Finding parent element in Protractor

To get the parent element, you can ...READ MORE

answered Mar 26, 2018 in Selenium by nsv999
• 5,090 points
904 views
0 votes
1 answer
0 votes
1 answer

Want to assert the row text in webtable

Hi, you can assert row text at ...READ MORE

answered Jun 10 in Selenium by Anvi
• 12,840 points
37 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
544 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
877 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
535 views
0 votes
1 answer

Getting a text of elements in div tag having same class name

Basically,there is no need to retrieve element ...READ MORE

answered May 17, 2018 in Selenium by Samarpit
• 5,130 points
4,786 views
0 votes
1 answer

How to find Elements by their Attribute in Python Selenium WebDriver

To find all the <td> tags which have attribute data-sortable-id you ...READ MORE

answered Jul 19, 2018 in Selenium by Samarpit
• 5,130 points
1,736 views