Thread.sleep(5000) alternatives to timeouts on the same screen

I am making a code in which to wait time I use Thread.sleep(5000) the problem is that this makes the code very unstable and I wanted to know if there is any alternative for waiting within the same screen
I already used

WebDriverWait wait = new WebDriverWait(driver,360);
return wait.until(ExpectedConditions.elementToBeClickable(By.xpath(“soul”)));

and the implicit wait but this only works when changing the screen

Not sure what you meant by that…
I think WebDriverWait is great if you use it correctly.
Forcing the thread to sleep is not ideal since you don’t want to make your test wait too much time when in real life, it could keep testing. As well, you don’t want it to wait less time then needed.

Why don’t you use WebDriverWait/FluentWait?

You can think of WebDriverWait as “Thread.sleep()” just with a condition so the method will know when it should stop waiting.

thanks for the answer but now I have the problem that when using a webdrive and waiting for the condition I get a [Original error: Error: socket hang up]

You need to give more info if you want help.
But, if you get this error then you might have an issue with appium server/driver/environment.

Thank you very much, additionally if you wanted to use the return wait.until(ExpectedConditions.elementToBeClickable in a login screen where there are no visible buttons, what would be the condition to send the respective text

I think I did not understand your question well, please try to explain again more clearly. It sounds like you want to click an invisible button…
But, in general, you should have a fixed id for the element you want to use. Your mobile developers should set this id through the mobile code and you should not work based on text values(although sometimes you might have to).