Alternative for Thread.sleep()

I writing a test that includes locking screen, waiting x seconds and unlocking screen for my android app.

For now I am using Thread.sleep(x * 1000).
Is there a way to replace the Thread.sleep to something else? (I am not looking to find element on screen or something similar, only wait a few seconds).

I tried using :
driver.manage().timeouts().implicitlyWait(x, TimeUnit.SECONDS);
But it didn’t work.

Thanks

You can use various Waits
Like below
public void waitForScreenToLoad(AppiumDriver lDriver, WebElement element, int seconds){

      WebDriverWait wait = new WebDriverWait(lDriver,seconds);
      wait.until(ExpectedConditions.visibilityOf(element));

}
follow below links for more info

1 Like

Hi upendraupadhyay,

I’m using POM model in appium, Can you suggest me where i have to use this? Is that in page class? Can you show me some example?