code: public static ExpectedCondition<Boolean> attributeToBe(final By locator, final String attribute,
                                                           final String value) {
      return new ExpectedCondition<Boolean>() {
        private String currentValue = null;
  
        @Override
        public Boolean apply(WebDriver driver) {
          WebElement element = driver.findElement(locator);
          currentValue = element.getAttribute(attribute);
          if (currentValue == null||currentValue.isEmpty()) {
            currentValue = element.getCssValue(attribute);
          }
          return value.equals(currentValue);
        }
  
        @Override
        public String toString() {
          return String.format("element found by %s to have value \"%s\". Current value: \"%s\"",
                               locator, value, currentValue);
        }
      };
    }
docs: An expectation for checking WebElement with given locator has attribute with a specific value
  
  @param locator   used to find the element
  @param attribute used to define css or html attribute
  @param value     used as expected attribute value
  @return Boolean true when element has css or html attribute with the value