@igal_epshtein i used similar to @Venkatesh without issues. BUT this is for WEB!
public Boolean waitElementForVisibility(List<WebElement> el) {
return waitElementForVisibility(el, 0, 10);
}
public Boolean waitElementForVisibility(List<WebElement> el, int num) {
return waitElementForVisibility(el, num, 10);
}
public Boolean waitElementForVisibility(List<WebElement> el, int num, int seconds) {
WebDriverWait wait = new WebDriverWait(driver, seconds);
try {
WebElement element = wait.until(
ExpectedConditions.visibilityOf(el.get(num)));
if (element.isDisplayed())
return true;
else
return false;
} catch (Exception e) {
return false;
}
}
for Android NATIVE you should use directly:
@AndroidFindBy(id = "title")
private List<AndroidElement> dialogTitle;
public String getDialogTitle() {
if (dialogTitle.isEmpty())
return null;
else
return dialogTitle.get(0).getText();
}
where timeout for dialogTitle is set in page init:
PageFactory.initElements(new AppiumFieldDecorator(driver, DEFAULT_WAIT_TIME, SECONDS), this);