1

Here's my question,

element.all(by.repeater('user in users')).then(function(rows) {
// would like to find an element in rows by.css for.exemple
}

EDIT :

I precise that I'm searching an element using

rows[rows.length - 1]

and I already tried

rows[rows.length - 1].element(by.css('.fa.fa-trash-o')).click();

But I got an error

element is not attached to the page document

Thanks for your answers !

giri-sh
  • 6,934
  • 2
  • 25
  • 50
Yoann Picquenot
  • 640
  • 10
  • 26
  • Are you sure that your page is not changing before you click the element `'.fa.fa-trash-o'`? Try waiting until the element is visible using `wait()` function and then probably click on it. Thanks – giri-sh Jan 07 '16 at 10:24
  • refer this one http://stackoverflow.com/questions/22757340/protractor-find-element-inside-a-repeater – RIYAJ KHAN Jan 07 '16 at 11:58

1 Answers1

3

This error usually occurs when the page is dynamically changing and you are trying to access some element that is yet to be visible/loaded. wait() function can be used to wait until element is loaded before accessing it. Here's how -

element.all(by.repeater('user in users')).then(function(rows) {
    var ele = rows[rows.length - 1].element(by.css('.fa.fa-trash-o'));
    browser.wait(protractor.ExpectedConditions.visibilityOf(ele), 10000);
    ele.click();
}

Hope it helps.

giri-sh
  • 6,934
  • 2
  • 25
  • 50