When running a test, the attribute of one or more elements can be changed at runtime. For instance, the text of a label can be modified with a new message, or a button can be enabled once certain steps have been completed. In such cases, a custom wait can be written on the attribute value of any of those elements.
This custom wait will wait 5 seconds before checking if the "disabled" attribute of the runTestButton element has changed to "false":
Boolean active = new WebDriverWait(driver, 5)
.until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.findElement(By.id("runTestButton")).
getAttribute("disabled").contains("false");
}
});