Time managing using Thread.sleep(1000)

Hi…I use Thread.sleep(1000);in every alternate line of code in my IOS test cases.Some times with in this time server clicks the particular element and execution continuous,some times element could not be tapped within time error comes and the rest of the all test cases fails to find next elements.
So how to handle?Please suggest me
Platform:IOS and Android
Appium version: 1.5.2
Simulator/Emulator or Real Device:Real Divide iPhone5s,Simulator iPhone6,emulator 6.0
language:Java
OS:MAC

Thanks,
Vani

Hi Vani,

Don’t use Thread.sleep() method. Use explicit wait method.

WebDriverWait wait = new WebDriverWait(Driver, seconds);
wait.until(ExpectedConditions.elementToBevisible(element));

1 Like

you can use wait until up-to that element visible .No need to put thread .sleep
WebDriverWait wait = new WebDriverWait(lDriver,seconds);
wait.until(ExpectedConditions.visibilityOf(element));

1 Like