Last active
August 29, 2015 14:07
-
-
Save dimmduh/02e5ee627fc32b1bd471 to your computer and use it in GitHub Desktop.
This file contains 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
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