code: public static <T> ExpectedCondition<T> refreshed(final ExpectedCondition<T> condition) {
      return new ExpectedCondition<T>() {
        @Override
        public T apply(WebDriver driver) {
          try {
            return condition.apply(driver);
          } catch (StaleElementReferenceException e) {
            return null;
          }
        }
  
        @Override
        public String toString() {
          return String.format("condition (%s) to be refreshed", condition);
        }
      };
    }
docs: Wrapper for a condition, which allows for elements to update by redrawing.
  
  This works around the problem of conditions which have two parts: find an element and then
  check for some condition on it. For these conditions it is possible that an element is located
  and then subsequently it is redrawn on the client. When this happens a {@link
  StaleElementReferenceException} is thrown when the second part of the condition is checked.
  
  @param condition ExpectedCondition to wrap
  @param <T>       return type of the condition provided
  @return the result of the provided condition