protractor icon indicating copy to clipboard operation
protractor copied to clipboard

How to click on a link within a ng-repeat

Open DivsBellur opened this issue 12 years ago • 3 comments

Hello,

I am having trouble getting to the objects within the below ng-repeat. I need to be able to click on the link "Tremor Nestle Toll House". I have tried different ways to get to that link but have not yet succeeded. So I tried to just click the row like below, which also did not succeed. Can you please help me the protractor code to do so?

Thanks, Divya

var firstRow = ptor.findElement(protractor.By.repeater('col in completeColumns')).row(0);

    firstRow.click();
<div class="row ng-scope card-inactive" ng-class="{true: 'card-active', false: 'card-inactive'}[card[recordIdentifier] == activeCard]" ng-repeat="card in cardModel">

    <div class="card-content no-card-options" ng-click="openCardDetails($index)" ng-class="{true: 'card-options', false: 'no-card-options'}[card.options.length > 0]">
        <ul ng-click="openDetails(card[recordIdentifier])">

            <li class="detail-item ng-scope" ng-if="displayCols" ng-repeat="col in completeColumns"></li>
            <li class="detail-item ng-scope" ng-if="displayCols" ng-repeat="col in completeColumns">
                <ul>
                    <li class="detail-content ng-binding">

                        Tremor Nestle Toll House

                    </li>
                    <li class="detail-name ng-binding">

                        Name

                    </li>
                </ul>
            </li>          
            <li class="detail-item ng-scope" ng-if="displayCols" ng-repeat="col in completeColumns"></li>
            <li class="detail-item ng-scope" ng-if="displayCols" ng-repeat="col in completeColumns"></li>
        </ul>
    </div>

DivsBellur avatar Oct 06 '14 03:10 DivsBellur

Try this, element.all(by.repeater('(col in completeColumns')).then(function(completeColumns) { completeColumns[1].click(); });

Or alternatively you can try this too - element(by.buttonText('Tremor Nestle Toll House')).click(); Or element(by.linkText("Tremor Nestle Toll House")).click();

smahalingam avatar Oct 06 '14 05:10 smahalingam

Thanks smahalingam!! Your first suggestion worked.

Divya

DivsBellur avatar Oct 06 '14 15:10 DivsBellur

Glad it worked

smahalingam avatar Oct 06 '14 15:10 smahalingam