code: public boolean isStaleElementException(WebDriverException e) {
          boolean result = false;
          if (e instanceof StaleElementReferenceException) {
              result = true;
          } else {
              String msg = e.getMessage();
              if (msg != null) {
                  result = msg.contains("Element does not exist in cache") // Safari stale element
                          || msg.contains("unknown error: unhandled inspector error: {\"code\":-32000,\"message\":\"Cannot find context with specified id\"}") // chrome error
                          || msg.contains("Error: element is not attached to the page document") // Alternate Chrome stale element
                          || msg.contains("can't access dead object"); // Firefox stale element
              }
          }
          return result;
      }
docs: Check whether exception indicates a 'stale element', not all drivers throw the exception one would expect...
  @param e exception caught
  @return true if exception indicated the element is no longer part of the page in the browser.