title: Test for the number of elements using Jasmine in AngularJS
body: <p>I am writing an end to end test using Jasmine for AngularJS.  I am using Protractor to run the test.  I have the following markup</p>
  
  <pre><code>&lt;ul class="phone-thumbs"&gt;
    &lt;li ng-repeat="img in phone.images"&gt;
      &lt;img ng-src="{{img}}"&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>And I want to test that for a particular page instance I have four of these images.  Here's what I have so far</p>
  
  <pre><code>describe('Phone detail view', function() {
  
      beforeEach(function() {
        browser.get('app/index.html#/phones/nexus-s');
      });
  
      it('should display four thumbnails on the nexus-s page', function() {
        expect(element(by.css('.phone-thumbs li img')).length()).toBe(4);
      });
    });
  </code></pre>
  
  <p>Problem is that I get an error saying </p>
  
  <pre><code>TypeError: Object #&lt;Object&gt; has no method 'length'
  </code></pre>
  
  <p>Where am I going wrong?</p>