code: public static ExpectedCondition<Boolean> titleContains(final String title) {
      return new ExpectedCondition<Boolean>() {
        private String currentTitle = "";
  
        @Override
        public Boolean apply(WebDriver driver) {
          currentTitle = driver.getTitle();
          return currentTitle != null && currentTitle.contains(title);
        }
  
        @Override
        public String toString() {
          return String.format("title to contain \"%s\". Current title: \"%s\"", title, currentTitle);
        }
      };
    }
docs: An expectation for checking that the title contains a case-sensitive substring
  
  @param title the fragment of title expected
  @return true when the title matches, false otherwise