Skip to content

Instantly share code, notes, and snippets.

Created November 12, 2014 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/91b3a1b6056c2457f020 to your computer and use it in GitHub Desktop.
Save anonymous/91b3a1b6056c2457f020 to your computer and use it in GitHub Desktop.
Predicate and Delegate in Java unit test
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