title: Interacting with element throw Stale Element Reference
body: <p>I have this site: <a href="http://embed.plnkr.co/Bs5iDqtXSSnvye2ORI6k/preview" rel="nofollow">http://embed.plnkr.co/Bs5iDqtXSSnvye2ORI6k/preview</a></p>
  
  <p>Code:</p>
  
  <pre><code>var app = angular.module('plunker', []);
  
  var a = new Array(1000);
  
  for (var i = 0; i&lt; 1000; i++) {
    a[i] = 'Name' + i;
  }
  
  app.controller('MainCtrl', function($scope, $interval) {
    $scope.names = a;
  
    $scope.start = function () {
      $interval(function () {
        $scope.names.pop();
      }, 50);
    }
  });
  </code></pre>
  
  <p>And the following spec:</p>
  
  <pre><code>'use strict';
  
  describe('Name list', function () {
      it('should get the text of the last name', function () {
          browser.driver.get('http://embed.plnkr.co/Bs5iDqtXSSnvye2ORI6k/preview');
          browser.switchTo().frame(browser.driver.findElement(protractor.By.tagName('iframe')));
          element(by.buttonText('start')).click();
          expect(element.all(by.tagName('span)).last().getText()).toBe('Name999');
      });
  });
  </code></pre>
  
  <p>And this config:</p>
  
  <pre><code>'use strict';
  
  // An example configuration file.
  exports.config = {
      baseUrl: 'http://localhost:3000',
      seleniumAddress: 'http://localhost:4444/wd/hub',
      specs: ['stale.spec.js']
  };
  </code></pre>
  
  <p>And when I run Protractor I get the following error:</p>
  
  <blockquote>
    <p>StaleElementReferenceError: stale element reference: element is not
    attached to the page document   (Session info: chrome=43.0.2357.81)<br>
    (Driver info: chromedriver=2.15.322455
    (ae8db840dac8d0c453355d3d922c91adfb61df8f),platform=Mac OS X 10.10.3
    x86_64) (WARNING: The server did not provide any stacktrace
    information) Command duration or timeout: 9 milliseconds For
    documentation on this error, please visit:
    <a href="http://seleniumhq.org/exceptions/stale_element_reference.html" rel="nofollow">http://seleniumhq.org/exceptions/stale_element_reference.html</a> Build
    info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26
    23:59:50' System info: host: 'ITs-MacBook-Pro.local', ip:
    '129.192.20.150', os.name: 'Mac OS X', os.arch: 'x86_64', os.version:
    '10.10.3', java.version: '1.8.0_31' Driver info:
    org.openqa.selenium.chrome.ChromeDriver Capabilities
    [{applicationCacheEnabled=false, rotatable=false,
    mobileEmulationEnabled=false,
    chrome={userDataDir=/var/folders/rr/63848xd90yscgwpkfn8srbyh0000gq/T/.org.chromium.Chromium.rarNyX},
    takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true,
    version=43.0.2357.81, platform=MAC, browserConnectionEnabled=false,
    nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true,
    webStorageEnabled=true, browserName=chrome, takesScreenshot=true,
    javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID:
    235ec977a69d98c7f5b75a329e8111b2</p>
  </blockquote>
  
  <p>This means that the element I try to interact with (getting the text of the element), isn't attached to the DOM anymore. This example is really my spec simplyfied. What really happens in my real spec is I try to get the text of the last element of a list of elements (generated by ng-repeat). What also happens is that the model updates, by removing the last element of the array representing the list of element. This example above is just something to reproduce the error (every time).</p>
  
  <p>If I comment out this line: <code>element(by.buttonText('start')).click();</code> the spec is successful.</p>