Is there a way in Katalon to wait() for a certain number of seconds?

Hello,

In some of our test scenarios we have to wait for at least 1 minute before doing an action. We are not waiting for an element to load or something but rather just waiting cause these are our system limitations.
We tried this:
WebUiCommonHelper.wait(60000)
but it triggers an error message stating:
05-24-2017 06:19:32 PM - [ERROR] - Test Cases/Login/Valid login inputs FAILED because (of) java.lang.IllegalMonitorStateException

Would you be able to clarify on the simple wait() action please ? Where did we make a mistake ? Based on the wait() function description it is still waiting for an element to load but how can we just let Katalon Studio wait for 1 minute for instance and then keep executing the code right after that.

Thanks!

Or Java function
Thread.sleep(int milliseconds)
if you want delay less than 1s

5 Likes

Thanks!

1 Like

Hi there,

Katalon Studio provides delay keyword for delaying the execution for the specified seconds. Please have a look here to check if it meets your expectation https://docs.katalon.com/display/KD/[Common]+Delay.

Thanks.

1 Like

Hey Alex,
you can simply use this built-in function of Katalon

WebUI.delay(5)

// 5 is the number of seconds you wait for before moving ahead

15 Likes

Hi,

Can we able to slowdown / speedup the script execution?
Example:
Let us consider that our script consist of 50 steps. Total Execution time of the script = 120 Seconds. I have to test my system under different network speed condition.

Question : Shall i make my script to slowdown such that complete execution of script should take 1.5 x (times) i.e. the script should take 180 Seconds to complete instead of actual time of 120 minutes without adding any additional sleep between the statements.

Thanks,
Santhan

Hi,

Maybe you can use “Delay between actions” in the Project Settings, see screenshot below.

Click on “Project → Settings” in the menu. Then expand the option “Default” under “Execution” and click on “Web UI”.

KatalonStudioDelayBetweenActions.png

7 Likes

use delay in steps or wait until keyword.

Alex Brohin said:

Hello,

In some of our test scenarios we have to wait for at least 1 minute before doing an action. We are not waiting for an element to load or something but rather just waiting cause these are our system limitations.

We tried this:

WebUiCommonHelper.wait(60000)

but it triggers an error message stating:

05-24-2017 06:19:32 PM - [ERROR] - Test Cases/Login/Valid login inputs FAILED because (of) java.lang.IllegalMonitorStateException

Would you be able to clarify on the simple wait() action please ? Where did we make a mistake ? Based on the wait() function description it is still waiting for an element to load but how can we just let Katalon Studio wait for 1 minute for instance and then keep executing the code right after that.

Thanks!

WebUI.delay() method delays the test case execution for a certain no of seconds.

Also, WebUI.waitForElementPresent() method waits for a certain element until its present. You can mention the no. of seconds for it to wait

5 Likes

WebUI.delay(4)

3 Likes

Depending onthe technology you are working with, I have also found it helpful to use the waitForAngularLoad or waitForJQuery on certain sites.

I wrap it in a method and have a global default wait value set to 2. Therefore I can either pass a wait amount or not depending on my requirements:

@Keyword

def comWait(def intWaitTime = null){

if(intWaitTime == null)

{

intWaitTime = GlobalVariable.intShortWait

}

int intWaitTimeMillie = intWaitTime * 1000

sleep(intWaitTimeMillie)

}

Yes I agree with some of the comments above, I myself uses “Delay” then set the number to 5 or 10 (sec.)

1 Like

Just an FYI for whoever comes across this thread in the future - delays are great and easy but they arent the most efficent way of writing the test. They can become a bad habit and can cause significant time loss in the future. The whole point of automation testing is to be fast and efficent.

Katalon has built in key words such as WebUI.waitForElementVisible(findTestObject(null), 0) where the 0 is the number of seconds the step will wait before it errors.

This way if the element is ready before x seconds it will move onto the next step, however a delay will continue to “delay” for the complete allotted time.

3 Likes

Just as an FYI, passing a zero will not work as expected. See this topic I wrote a while back calling for this to be fixed.

1 Like

Hii I use time.sleep(100) for file uploading . i want after file uploading Robot automatically click without using time.sleep(100) method. how to i solve it help me .

                                                                                                       Regarding
                                                                                                     Pankaj kumar

use Jmeter for that

WebUI.delay(5) // to wait 5 seconds

WebUI.delay will do everything you want it to do but its bad practice for automation as you are hard coding a time for the test to wait. You may run the test another time and get a lag spike and the it actually hangs for longer than 5 seconds, you will then go in and increase the seconds delay from 5 to 10 because you want to “fix” the test. You then have 10 seconds of delay every test, even when the test may be ready after 2 seconds to proceed to the next step. This can grow and grow till eventually you could have 7 hours worth of tests, which are only perfoming actions for 2 hours of that time, the rest of the time its just perfoming your hard coded waits. Do you get where im coming from?

The ultimate goal is to wait for jQuery.active to be 0 before you can proceed to the next step, but a simpler solution is to use on of the inbuilt waitFor… methods that katalon have included. This will only wait the time needed on that occasion, up to a certain time you will set before it times out.

1 Like