title: Protractor throws StaleElementReferenceError when using element.all to iterate through a table
body: <p>I have protractor test which will iterate on a table with 6 columns. I am iterating on the table using element.all and then search for specific text in first column. If matches, check the status in 6th column, if it is set to Activate, click the matched row which will take it to another page, perform an operation, come back to table page, reiterate on the same table and check for that specific text and validate the final status to be Activate again.</p>
  
  <p>The test runs fine but fails with below error.</p>
  
  <pre><code>StaleElementReferenceError: stale element reference: element is not attached to the page document
  
  element.all(by.css('tbody tr')).each(function(item){
      var count=0;
      var pass=0;
      //TEST VALUES BELOW
      var appNameCreated="Test App 534";
      //TEST VALUES ABOVE
      item.element(by.css('td:nth-child(1)')).getText().then(function(appname){
          if(appname==appNameCreated){
              console.log(appname,appNameCreated);
              item.element(by.css('td:nth-child(6)')).getText().then(function(result){
                  pass += 1;
                  console.log(result);
                  if (result=="Activated"){
                  //if (result==data.resultSubmit){
                      item.element(by.css('td:nth-child(1)')).element(by.css('a')).click().then(function(){
                      browser.sleep(4000);
                      });
                      element(by.id("btnTab3")).element(by.xpath('span')).click();
                      browser.wait(EC.visibilityOf(element(by.xpath('/html/body/gft-root/section/div[2]/app-onboard-list/div[4]/div[3]/table/tbody/tr[1]/td[1]'))),15000);
                      element(by.id("button-basic")).click();
                      element.all(by.css('ul[class="dropdown-menu"]')).each(function(item1){
                          item1.element(by.css('li:nth-child(7)')).element(by.css('a')).click();
                      })
                      element.all(by.css('tbody tr')).each(function(item2){
                          item2.element(by.css('td:nth-child(1)')).getText().then(function(appname1){
                              if(appname1==appNameCreated){
                                  item2.element(by.css('td:nth-child(6)')).getText().then(function(resultFin){
                                      console.log(resultFin);
                                      browser.actions().mouseMove(item2.element(by.css('td:nth-child(1)'))).perform();
                                      expect(resultFin).toBe(data.resultFinal);
                                  })
                              }   
                          })
                      })
                  }           
              })
          }
      })
  })
  </code></pre>