Protractor - clicking a link in a list

angularjs, jasmine, javascript, protractor

Solution

element.all(by.repeater('task in tasks')).
  get(1).
  element(by.linkText('Complete')).
  click()

or

element.all(by.repeater('task in tasks')).
  get(1).
  $('a').
  click()

Problem

Given a todo app that has a list of tasks: Walk the dog, Eat lunch, Go shopping. Each task has a 'complete' link. Using Protractor, how do I click the complete link for the second task 'Eat lunch'? Preferably I'd like to do this without using indices in my test. The html structure is like so... ``` <ul class="pending"> <li ng-repeat="task in tasks"> {{task.name}} <a href='#'>Complete</a> </li> </ul> ``` This seems like a common situation so surely there has to be a simple solution that I'm overlooking. Thanks in advance

Original source