Hello Katalon users,
Please I need a help with following issue:
You want to verify an object on the page. That object might be there or not, depends if the user has set in his profile an avatar image, if not, then there is a blank circle icon instead of his image.
Now I’m trying to verify following. If there is not an image, then look for the icon and continue the test. If there is an image, then continue the test (as the icon then is unimportant and is not there anyway).
I’m using right now this code, which on failure is continuing the test:
WebUI.verifyElementPresent(findTestObject(‘Top Navigation/img_User_img’), 1, FailureHandling.CONTINUE_ON_FAILURE)
WebUI.verifyElementPresent(findTestObject(‘Top Navigation/img_User_icon’), 1, FailureHandling.CONTINUE_ON_FAILURE)
In that case I will always receive one error(depends if the avatar image was set or not), that’s not really a problem. Problem is when I want to add an action. It can not run an action on a non-existing object, therefore I do not know right now how to deal with this, if this should be all in a if-else statement or in some other statement?
I need two packages of action now, if there is an image do this and continue the test, else look for icon and do this and continue the test.
For that I have tried this code:
if (WebUI.verifyElementPresent(findTestObject(‘Top Navigation/img_User_img’), 1, FailureHandling.OPTIONAL)) {
CustomKeywords.'com.reusableComponents.HighlightElement.run'(findTestObject('Top Navigation/img\_User\_img'))
}
else
(WebUI.verifyElementPresent(findTestObject(‘Top Navigation/img_User_icon’), 1, FailureHandling.OPTIONAL)) {
CustomKeywords.'com.reusableComponents.HighlightElement.run'(findTestObject('Top Navigation/img\_User\_icon'))}
The action is a highlight custom keyword, it highlights with a yellow color the object so you will see on the screen if it was verified by Katalon or not.
But I’m getting this error:
Test Cases/EMT/Assertions FAILED because (of) groovy.lang.MissingMethodException: No signature of method: java.lang.Boolean.call() is applicable for argument types: (Script1537956972672$_run_closure1) values: [Script1537956972672$_run_closure1@522b2631]
Possible solutions: wait(), any(), wait(long), each(groovy.lang.Closure), any(groovy.lang.Closure), and(java.lang.Boolean)
Script is working to the point when there is the image set, but not if there is the icon.
Any help on how to make this two packages of action is much appreciated.