Skip to content

Instantly share code, notes, and snippets.

@seleniumgists
Created May 21, 2020 08:36
Show Gist options
  • Select an option

  • Save seleniumgists/dc0e3182908f1fdc63c511cbda38eb6f to your computer and use it in GitHub Desktop.

Select an option

Save seleniumgists/dc0e3182908f1fdc63c511cbda38eb6f to your computer and use it in GitHub Desktop.
generated automatically from #selenium on seleniumhq slack
protected static WebElement getElement(By locator) {
try {
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(Constants.MAX_WAIT_SECONDS_EXPLICIT));
wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
} catch (Exception tex) {
logOutput("FAIL", tex.getMessage());
}
if (!driver.findElements(locator).isEmpty()) {
return driver.findElements(locator).get(0);
} else {
logOutput("FAIL", "Could not find object - " + locator.toString());
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment