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,320 points
10,199 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,910 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 27, 2018 in Selenium by nsv999
• 5,500 points
3,733 views
0 votes
1 answer

Find element with specific text in selenium

You can use Xpath as the locator ...READ MORE

answered Jan 9, 2019 in Selenium by Nabarupa
8,334 views
0 votes
1 answer

Want to assert the row text in webtable

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

answered Jun 10, 2019 in Selenium by Anvi
• 14,150 points
1,061 views
0 votes
2 answers

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,500 points
13,772 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,187 views
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,910 points
7,263 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,901 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,910 points
22,865 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,910 points
10,594 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP