Skip to content

Instantly share code, notes, and snippets.

@dimmduh
Last active August 29, 2015 14:07
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 dimmduh/02e5ee627fc32b1bd471 to your computer and use it in GitHub Desktop.
Save dimmduh/02e5ee627fc32b1bd471 to your computer and use it in GitHub Desktop.
Utils.waitElement(new String[]{"firstElementId", "secondElemntId"});
public class Utils {
public static WebDriver driver;
public static WebElement waitElement(final String[] elementIds, int timeout) {
return (new WebDriverWait(driver, timeout))
.until(new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver d) {
WebElement el;
for (Iterator<String> i = Arrays.asList(elementIds).iterator(); i.hasNext(); ) {
String elementId = i.next();
try {
el = d.findElement(By.id(elementId));
if (el != null && el.isDisplayed()) {
return el;
}
} catch (org.openqa.selenium.NoSuchElementException ex) {
// ignore as we are waiting for that to stop
}
}
return null;
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment