I have created a utility class where I have:
public void waitForScreenToLoad(AndroidDriver lDriver, WebElement element, int seconds){
WebDriverWait wait = new WebDriverWait(lDriver,seconds);
wait.until(ExpectedConditions.visibilityOf(element));
}
and my main class of sign in has:
@Test (priority = 0)
public void SignIn() throws InterruptedException, IOException {
Thread.sleep(8000);
MobileElement ele = (MobileElement) driver.findElementByAccessibilityId("abcde");
MobileElement sign = (MobileElement) driver.findElementByAccessibilityId("Sign in");
sign.click();
// Thread.sleep(8000);
waitForScreenToLoad(driver, ele, 120);
captureScreenshot(driver,folder_name,df);
Thread.sleep(2000);
}
They are both in the same package. Element ele
is present on both pages before and after sign in. The wait does not work but, if I use Thread.sleep
it works and I am able to take a screenshot.
Can anybody tell me what is wrong with my code? or if using Thread.sleep
so frequently is ok to make it work?