jimakos17
jimakos17

Reputation: 935

click on a button inside ng-repeat

I'm trying to find an element which is a button and click on it in protractor but I'm getting an error element is not visible.

<li data-ng-repeat="dog in dogs">
<button type="button" name="dog1" class="dog1">&gt;</button>
<button type="button" name="dog2" class="dog2">&gt;</button>
<button type="button" name="dog3" class="dog3">&gt;</button>
<button type="button" name="dog4" class="dog4">&gt;</button>
</li>

When I use ptor.findElement(protractor.By.className('dog1')).click(); I'm getting an error element is not visible.

I tried

var dog;

 dog = ptor.findElements(protractor.By.repeater('dog in dogs')).then(function(rows) {
  rows.forEach(function (row) {
    row.getText().then(function (rows) {
     console.log(rows);
    });
   });
 });

and I print the rows but I still cannot click on the nested element.

I use protractor Version 0.12.1 Any idea how to click on that nested element? Thank you

Upvotes: 2

Views: 1996

Answers (1)

iwein
iwein

Reputation: 26161

Just use css grammar for this (as in Richards comment):

element(by.css('li:nth-child(3)>.my-class'));

Upvotes: 2

Related Questions