code: public static ExpectedCondition<Boolean> urlToBe(final String url) {
      return new ExpectedCondition<Boolean>() {
        private String currentUrl = "";
  
        @Override
        public Boolean apply(WebDriver driver) {
          currentUrl = driver.getCurrentUrl();
          return currentUrl != null && currentUrl.equals(url);
        }
  
        @Override
        public String toString() {
          return String.format("url to be \"%s\". Current url: \"%s\"", url, currentUrl);
        }
      };
    }
docs: An expectation for the URL of the current page to be a specific url.
  
  @param url the url that the page should be on
  @return <code>true</code> when the URL is what it should be