title: Protractor - TypeError: undefined is not a function
body: <p>This question serves two purposes, to try to solve this specific error and to try to understand protractor best practices. So, I have the following failing code for the test:</p>
  
  <pre><code>var newRow = element.all(by.repeater("employee in ec.employees")).last();
  
  newRow.then(function(row) {
      row.findElements(by.tagName("td")).then(function(cells) {
          expect(cells.get(0).getText()).toBe("9988776655000");
          expect(cells.get(1).getText()).toBe("Test name");
          expect(cells.get(2).getText()).toBe("Test surname");
      });
  });
  </code></pre>
  
  <p>The reason: </p>
  
  <blockquote>
    <p>TypeError: Undefined is not a function</p>
  </blockquote>
  
  <p>and it's pointing to the 2nd row of code <code>newRow.then(...)</code>.</p>
  
  <p>My relevant HTML:</p>
  
  <pre><code>&lt;tr ng-repeat="employee in ec.employees"&gt;
      &lt;td&gt;{{employee.jmbg}}&lt;/td&gt;
      &lt;td&gt;{{employee.name}}&lt;/td&gt;
      &lt;td&gt;{{employee.surname}}&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>Now, I've already seen dozens of posts for this error on SO, but all are specific and as far as I could find there wasn't one similar to my case.
  So, other than the question of why my code doesn't work, I wanted to ask was it better to use <code>ElementFinder.findElement/s</code> function, or is there an alternative?</p>