Created
November 12, 2014 04:17
-
-
Save anonymous/91b3a1b6056c2457f020 to your computer and use it in GitHub Desktop.
Predicate and Delegate in Java unit test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void authenticate() { | |
this.authenticateButton.click(); | |
new WebDriverWait(driver, 30).until(authenticated()); | |
} | |
private Predicate<WebDriver> authenticated() { | |
return new Predicate<WebDriver>() { | |
@Override public boolean apply(WebDriver driver) { | |
return isAuthenticated(); | |
} | |
}; | |
} | |
//delegate method here | |
private boolean isAuthenticated() { | |
return (Boolean) executor().executeScript("return authenticated;"); | |
} | |
private JavascriptExecutor executor() { | |
return (JavascriptExecutor) driver; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://howtodoinjava.com/2014/04/04/how-to-use-predicate-in-java-8/