code: public static ExpectedCondition<Boolean> invisibilityOfAllElements(
      final List<WebElement> elements) {
      return new ExpectedCondition<Boolean>() {
  
        @Override
        public Boolean apply(WebDriver webDriver) {
          return elements.stream().allMatch(ExpectedConditions::isInvisible);
        }
  
        @Override
        public String toString() {
          return "invisibility of all elements " + elements;
        }
      };
    }
docs: An expectation for checking all elements from given list to be invisible
  
  @param elements used to check their invisibility
  @return Boolean true when all elements are not visible anymore