title: Selenium WebDriverJS thenCatch not catching StaleElementException
body: <p>I am running node.js and Selenium WebDriverJS. One of my tests is failing with the following error:</p>
  
  <pre><code>UnknownError: unknown error: Runtime.evaluate threw exception: Error: element is not attached to the page document
  </code></pre>
  
  <p>I understand that this is essentially a StaleElementReferenceException, but I have not been able to find a reliable workaround. I have tried the following without success:</p>
  
  <ol>
  <li><p>waiting for the element to appear on the page before finding and clicking on the element</p>
  
  <pre><code>waitForElement: function (selector, timeout) {
      if (typeof(timeout) === 'undefined') { timeout = 3000; }
      driver.wait(function() {
          return driver.findElements(selector).then(function(list) {
              return list.length &gt; 0;
          });
      }, timeout);
  }
  </code></pre></li>
  <li>waiting an explicit time period (<code>driver.sleep(1000)</code>) before finding and clicking on the element</li>
  <li>finding the element multiple times (using <code>.findElement()</code>) before clicking on the element</li>
  <li><p>using a promise chain to catch any errors and try re-clicking on the element</p>
  
  <pre><code>driver.getTitle().then(function(title) {
      driver.findElement(webdriver.By.xpath(...)).click();
  }).thenCatch(function(e) {
      driver.findElement(webdriver.By.xpath(...)).click();
  });
  </code></pre></li>
  <li><p>using a promise chain with a recursive function to keep trying to re-click the element</p>
  
  <pre><code>var getStaleElement = function(selector, callback) {
      var element = driver.findElement(selector);
      callback(element);
  }).thenCatch(function(e) {
      getStaleElement(selector, callback);
  });
  
  var clickSelf = function(ele) { return ele.click() };
  
  driver.getTitle().then(function(title) {
      driver.findElement(webdriver.By.xpath(...)).click();
  }).thenCatch(function(e) {
      getStaleElement(webdriver.By.xpath(...), clickSelf);
  });
  </code></pre></li>
  <li>methods 4 and 5 using the errback argument of <code>.then()</code> in place of <code>.thenCatch()</code></li>
  <li>combinations of the above</li>
  </ol>
  
  <p>It seems like Selenium is not able to catch this specific error. I used print statements to confirm that other errors such as NoSuchElementError are caught by <code>.thenCatch()</code>. Is there a workaround that will allow me to deal with stale elements?</p>