Waiting for activity visiblity

Please provide any method for waiting until activity visible or not for android.

You can obtain the current activity using driver.current_activity or the equivalent in whatever language you’re using. You can set up a polling loop to wait for the activity to match (or not match) the desired value.

1 Like

public boolean isDisplayedScreen(String screenName, int waitSeconds) throws InterruptedException {
boolean isDisplayed = false;
if (screenName !=null && !screenName.isEmpty()) {
for (int i = 0; i < waitSeconds; i++) {
Thread.sleep(1000);
if (driver instanceof AndroidDriver &&
((AndroidDriver) driver).currentActivity().equalsIgnoreCase(screenName)) {
isDisplayed = true;
break;
}
}
}
return isDisplayed;
}