How to wait for element without setting a time

Good Afternoon,

I want to add a Wait For Element to be Clickable but don’t want to set a certain time it must wait until its clickable. Is that possible? Can I just add the line but not set a certain timer?

It might not be elegant but you could do this

while(WebUI.WaitForElementNotClickable(TestObject,1))
{
}

Thanks Ill give it a go

Just note you can get infinite loop and it’s good practice to have a timer, at least a long one.

2 Likes

So this is my code that I added
My Code
while(WebUI.WaitForElementClickable(‘Object Repository/ManagerBasicFunctions/Page/PopupError’)){
//Click
WebUI.click(findTestObject(‘Object Repository/ManagerBasicFunctions/Page/PopupError’))
}

But I keep getting a error code and will post my error code
08-15-2019 02:12:25 PM Test Cases/Manager/BasicManagerFunction001

Elapsed time: 24.196s

Test Cases/Manager/BasicManagerFunction001 FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.WaitForElementClickable() is applicable for argument types: (java.lang.String) values: [Object Repository/ManagerBasicFunctions/Page/PopupError]
Possible solutions: waitForElementClickable(com.kms.katalon.core.testobject.TestObject, int), waitForElementClickable(com.kms.katalon.core.testobject.TestObject, int, com.kms.katalon.core.model.FailureHandling)
at BasicManagerFunction001.run(BasicManagerFunction001:47)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)

First, if you want to wait until the element is clickable you need to use “WebUI.WaitForElementNotClickable”.

while(WebUI.WaitForElementNotClickable(findTestObject(‘Object Repository/ManagerBasicFunctions/Page/PopupError’))

Also, parameter for this function is a testObject and you are giving him a string, that’s why you get that error. You have to use findTestObject(“Path to object in object repository”).

Above code should work :slight_smile:

To add to this…

The error in the error log:
Possible solutions: waitForElementClickable(com.kms.katalon.core.testobject.TestObject, int)

waitForElementClickable needs a TestObject AND an int as parameters. The int is the amount of time you want to wait. However if this is in a while loop then I believe this will run indefinitely. It would be better to just call it without the while and set a time limit on it.

This is what I was thinking also but for some reason it does fail the entire test after 20-30secs. It doens’t fully wait for the popup box to actually show.

By default I think the timeout is 30 seconds. If you go to Project>Execution you can increase the wait time to something longer.

After changing my code and adding the findTestObjectin my script and will post my code

//WebUI.waitForElementClickable(findTestObject('Page/button_OK'), 60)
while(WebUI.WaitForElementNotClickable(findTestObject('Object Repository/ManagerBasicFunctions/Page/PopupError'))){
	//Click
	WebUI.click(findTestObject('Object Repository/ManagerBasicFunctions/Page/PopupError'))

}

08-15-2019 03:04:10 PM Test Cases/Manager/BasicManagerFunction001

Elapsed time: 24.276s

Test Cases/Manager/BasicManagerFunction001 FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.WaitForElementNotClickable() is applicable for argument types: (com.kms.katalon.core.testobject.TestObject) values: [TestObject - 'Object Repository/ManagerBasicFunctions/Page_Kronos Workforce Central(R) 814  web52/PopupError']
Possible solutions: waitForElementNotClickable(com.kms.katalon.core.testobject.TestObject, int), waitForElementNotClickable(com.kms.katalon.core.testobject.TestObject, int, com.kms.katalon.core.model.FailureHandling), waitForElementClickable(com.kms.katalon.core.testobject.TestObject, int)
	at BasicManagerFunction001.run(BasicManagerFunction001:47)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)

Thank you I just changed the time on it. Hopefully we shall get different results.

1 Like

Try something like this
WebUI.WaitForElementNotClickable(findTestObject('ManagerBasicFunctions/Page/PopupError'), 0)

I believe you don’t need the ‘Object Repository’ in your object path. And also the WaitForElementNotClickable needs an int as a second parameter. So you add the ‘, 0)’ with the function.

I added the “0” in my code and still got another error. I will post my code and the error code.

//WebUI.waitForElementClickable(findTestObject('Page/button_OK'), 60)
while(WebUI.WaitForElementNotClickable(findTestObject('Object Repository/ManagerBasicFunctions/Page/PopupError'),0)){
	//Click
	WebUI.click(findTestObject('Object Repository/ManagerBasicFunctions/Page/PopupError'))
	
}

Error
08-20-2019 10:32:39 AM Test Cases/Manager/BasicManagerFunction001

Elapsed time: 23.861s

Test Cases/Manager/BasicManagerFunction001 FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.WaitForElementNotClickable() is applicable for argument types: (com.kms.katalon.core.testobject.TestObject, java.lang.Integer) values: [TestObject - 'Object Repository/ManagerBasicFunctions/Page/PopupError', ...]
Possible solutions: waitForElementNotClickable(com.kms.katalon.core.testobject.TestObject, int),

Normally, if you use 0 as timeout, it will use 30 instead. You better use 1 if you want a really short timeout or 60 if you want maximum timeout. Since you’re using it in a infinite loop, 1 or 60 shouldn’t make any difference.

Regarding your error, I don’t understand it. It says you use TestObject and Integer parameter and the function only take TestObject and int. It seems correct to me.

Yeh I am extremely confused at this point. I’m still trying and just having the wait time at 105 currently. I’m just waiting and trying to use my stopwatch to time how long it takes for the popup. Is it anyway possible I can have it load the page and it give me the result of how long it takes to load a certain element?

@Nilau @Eric_Montou

So I tried updating my code and used this type and added the interger in the same line, but I’m not sure if this is the cause of the error code.

while(WebUI.WaitForElementNotClickable(findTestObject('Object Repository/ManagerBasicFunctions/Page/PopupError',2))){
	//Click
	WebUI.click(findTestObject('Object Repository/ManagerBasicFunctions/Page/PopupError'))
	
}

Error
08-20-2019 11:19:00 AM Test Cases/Manager/BasicManagerFunction001

Elapsed time: 23.063s

Test Cases/Manager/BasicManagerFunction001 FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.testobject.ObjectRepository.findTestObject() is applicable for argument types: (java.lang.String, java.lang.Integer) values: [Object Repository/ManagerBasicFunctions/Page_Kronos Workforce Central(R) 814  web52/PopupError, ...]
Possible solutions: findTestObject(java.lang.String), findTestObject(java.lang.String, java.util.Map), findRequestObject(java.lang.String, java.io.File)
	at BasicManagerFunction001.run(BasicManagerFunction001:48)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)

I think I see it. The parenthesis is not correct. There should be a closing parenthesis before the “,2”.

while(WebUI.waitForElementNotClickable(findTestObject('ObjectRepository/ManagerBasicFunctions/Page/PopupError'),2))

Before we get ahead of ourselves… can you verify this is the correct path to your object?

Object Repository/ManagerBasicFunctions/Page/PopupError

Object Repository is not typically used in the path unless you added a folder called Object Repository under the Object repository folder… which sounds redundant.

ManagerBasicFunctions/Page/PopupError

This path looks correct to me.

The path is correct I have just been removing personal info with every upload.

1 Like

Ok cool just wanted to make sure!

Try this:

while(WebUI.waitForElementNotClickable(findTestObject(‘Object Repository/ManagerBasicFunctions/Page/PopupError’),2)){
//Click
WebUI.click(findTestObject(‘Object Repository/ManagerBasicFunctions/Page/PopupError’))

}

The first change I made was where the parenthesis were (Nilau also noticed this).
The second change I made was change the waitForElementNotClickable method to lowercase. Usually methods are lowercase while classes are Upper case. It might have issue with that.