For Multiple Webview based Mobile App (iOS app built using Cordova, PhoneGap, XCode), I have created below method to check if element is present. Kindly suggest if below snippet makes sense? as traditional wrapper functions based on traditional Explicit waits are not working reliably.
public boolean waitForElemToBeAvailable(final By by, final int timeout, int retries) {
WebDriverWait wait = new WebDriverWait(appiumDriver, timeout);
boolean success = false;
final long waitSlice = timeout/retries;
if(retries>0){
List<WebElement> elements = appiumDriver.findElements(by);
if(elements.size()>0){
success = true;
return success;
}else {
appiumDriver.manage().timeouts().implicitlyWait(waitSlice, TimeUnit.SECONDS);
retries--;
}
}
return success;
}
Thanks