Difference between Thread.sleep() VS WebUI.delay()

Difference between Thread.sleep() VS WebUI.delay()

When do I use Thread.sleep() ? And, when do I use WebUI.delay() ?

Both Method serves the same purpose. So it’s upto you.

Thread.sleep() method can be used to pause the execution of current thread for specified time in milliseconds.

Thread.sleep(2000); // Meaning Script will pause for 2 seconds.

//Delay the execution for 2 seconds. Thiis is a inbuilt keyword in Katalon for web testing

1 Like

this may be true only in single threading context.
when multithreading programming is used, and particularly if inter-process communication is desired … those two methods will behave totaly different.
just saying …

thread.sleep will suspend the thread for the given time … not pausing it. once resumed will continue exactly from where he was suspended.

using delay, thread is still active, but paused.

Python sleep() will pause for an hour, day or whatever if given the proper value. It does not allow other processes take place (in same script) however. A better way is to use an event which will create an event on timeout.