Skip to content

Instantly share code, notes, and snippets.

@tourdedave
Created March 23, 2017 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tourdedave/e19109c5b5a26a39602bf3ccee512ad1 to your computer and use it in GitHub Desktop.
Save tourdedave/e19109c5b5a26a39602bf3ccee512ad1 to your computer and use it in GitHub Desktop.
// in Base Page Object
public Boolean isDisplayed(By locator) {
try {
return find(locator).isDisplayed();
} catch (org.openqa.selenium.NoSuchElementException exception) {
return false;
}
}
public Boolean isDisplayed(By locator, Integer timeout) {
try {
WebDriverWait wait = new WebDriverWait(driver, timeout);
wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
} catch (org.openqa.selenium.TimeoutException exception) {
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment