This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
3 / 3
Sep 2017

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

  • created

    Aug '17
  • last reply

    Sep '17
  • 2

    replies

  • 669

    views

  • 2

    users

  • 1

    like

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 month later

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;
}