mac_new
mac_new

Reputation: 31

Protractor ng-repeat

I am trying to select all the todo's on https://www.angularjs.org/. However its only changing the first one. How do I select all the elements:

element.all(by.repeater('todo in todoList.todos')).then(function(rows) {
    for (var i = 0; i < rows.length; ++i) {                
        element.all(by.repeater('todo in todoList.todos')).get(i).element(by.model('todo.done')).click();
    } 
});

Upvotes: 1

Views: 492

Answers (2)

shruti dalvi
shruti dalvi

Reputation: 281

var todos = element.all(by.repeater('todo in todoList.todos'));
todos.get(1).click();
todos.get(2).click();

element.all will collect all elements of givent locator and get() will select the element specific element. It works like array.

Upvotes: 0

alecxe
alecxe

Reputation: 474271

You need the .each():

var todos = element.all(by.repeater('todo in todoList.todos'));
todos.each(function(todo) {
    todo.element(by.model('todo.done')).click();

    browser.sleep(1000);  // hardcoded delay 
});

Upvotes: 2

Related Questions