title: Chaining all statements in protractor
body: <p>My first stack overflow question....</p>
  
  <p>I'm trying to chain an all statements in protractor but I'm getting the error.</p>
  
  <pre><code>TypeError: Object [object Object] has no method 'all'
  </code></pre>
  
  <p>I'm looking at the API code on the following page</p>
  
  <p><a href="http://angular.github.io/protractor/#/api?view=ElementArrayFinder.prototype.all" rel="noreferrer">http://angular.github.io/protractor/#/api?view=ElementArrayFinder.prototype.all</a></p>
  
  <p>Which indicates that you can use element.all(locator).all(locator)</p>
  
  <p>it gives this as an example</p>
  
  <pre><code>var foo = element.all(by.css('.parent')).all(by.css('.foo'))
  </code></pre>
  
  <p>my code seems to be very similar, and I'm confused why I'm getting this error. I've tried structuring the code exactly like they have it on the API example. I've also tried doing element.all(locator).element.all(locator).</p>
  
  <p>My GOAL here is to take a Ng-repeat of AREFS; find the one that has the text equal to r_string (which is a string generated earlier and added to the page; expect that element to exist; click that element;</p>
  
  <p>Some Attempts:</p>
  
  <pre><code>    var parent = element.all(by.repeater('labgroup in LabGroupService.allLabGroups'));
      var child = parent.all(by.xpath('//option[text() = \'' + r_string + '\']'));
      expect(child.count()).toBe('1');
  </code></pre>
  
  <p>and</p>
  
  <pre><code>    var elem = element.all(by.repeater('labgroup in LabGroupService.allLabGroups')).all(by.xpath('//option[text() = \'' + r_string + '\']'));
      expect(elem.count()).toBe('1');
  </code></pre>
  
  <p>Finally here is a snippet of the HTML i'm working with.</p>
  
  <pre><code>        &lt;a ui-sref="root.user-management.labgroup({labgroupID: labgroup.id})" class="ng-binding" href="#/management/labgroup/43"&gt;1kvub4wgCvY9QfA&lt;/a&gt;
      &lt;/dd&gt;&lt;!-- end ngRepeat: labgroup in LabGroupService.allLabGroups --&gt;&lt;dd ng-repeat="labgroup in LabGroupService.allLabGroups" class="ng-scope"&gt;
          &lt;a ui-sref="root.user-management.labgroup({labgroupID: labgroup.id})" class="ng-binding" href="#/management/labgroup/47"&gt;3PNsny8lUMlMwBw&lt;/a&gt;
      &lt;/dd&gt;&lt;!-- end ngRepeat: labgroup in LabGroupService.allLabGroups --&gt;&lt;dd ng-repeat="labgroup in LabGroupService.allLabGroups" class="ng-scope"&gt;
          &lt;a ui-sref="root.user-management.labgroup({labgroupID: labgroup.id})" class="ng-binding" href="#/management/labgroup/42"&gt;c3NOI7Z3933ui3a&lt;/a&gt;
      &lt;/dd&gt;&lt;!-- end ngRepeat: labgroup in LabGroupService.allLabGroups --&gt;&lt;dd ng-repeat="labgroup in LabGroupService.allLabGroups" class="ng-scope"&gt;
  </code></pre>
  
  <p><strong>Edit----------------------------------------------------------------------------------------</strong></p>
  
  <p>I'm starting to wonder if this is a version error or maybe a protractor error. In an attempt to debug I've literally included the source code from the API page.</p>
  
  <pre><code>    &lt;div id='id1' class="parent"&gt;
        &lt;ul&gt;
          &lt;li class="foo"&gt;1a&lt;/li&gt;
          &lt;li class="baz"&gt;1b&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/div&gt;
      &lt;div id='id2' class="parent"&gt;
       &lt;ul&gt;
         &lt;li class="foo"&gt;2a&lt;/li&gt;
         &lt;li class="bar"&gt;2b&lt;/li&gt;
       &lt;/ul&gt;
       &lt;/div&gt;
  </code></pre>
  
  <p>and the example from the source page.</p>
  
  <pre><code>var foo = element.all(by.css('.parent')).all(by.css('.foo'))
  expect(foo.getText()).toEqual(['1a', '2a'])
  </code></pre>
  
  <p>I'm still getting that same error.</p>
  
  <pre><code>TypeError: Object [object Object] has no method 'all'
  </code></pre>
  
  <p><strong>Edit 2-------------------------------------------------------------------------------</strong></p>
  
  <p>I managed to solve this issue by adding a 'data-class = labgroup-link' into the actual html code and by using this protractor code.</p>
  
  <pre><code>    element.all(by.css('[data-class="labgroup-link"]')).filter(function(elem, index) {
          return elem.getText().then(function(text) {
              return text === r_string;
          });
      }).then(function(filteredElements) {
          expect(filteredElements[0].isPresent()).toBe(true);
          filteredElements[0].click();
          ptor.sleep(100);
      });
  </code></pre>
  
  <p><strong>Solution ----------------------------------------</strong></p>
  
  <p>Had to upgrade protractor to get the latest API.</p>