Using appium + selenium + java. Trying to wait for mobile element with specific text.
In mobile application I am login to page, and during login have android.widget.TextView(0) with text, so I am checking this text and if new element android.widget.TextView(0) with different text show up then I can go with other steps. When new element show up old one does not exists
For that using following code but then I can see
Cached elements 'By.clazz: android.widget.TextView' do not exist in DOM anymore
Code:
public static MobileElement waitForElementText(AndroidDriver driver, int index, String text, int timeout) {
List<MobileElement> mobileElement = null;
do {
mobileElement = new WebDriverWait(driver, timeout)
.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.className("android.widget.TextView")))
.stream().map(element -> (MobileElement) element).collect(Collectors.toList());
System.out.println("waiting for: " + text + " found: " + mobileElement.get(index).getText());
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} while (mobileElement.get(index).getText() != text);
System.out.println(mobileElement.get(index).getText());
return mobileElement.get(index);
}
any ideas what am I doing wrong?