def winAddJob = 'Help Desk/winAddJob'
if (Windows.verifyElementPresent(findWindowsObject(winAddJob), 10)) {
// Element is present; continue with your logic
Windows.click(findWindowsObject('Help Desk/btnYesAddJob'))
Windows.click(findWindowsObject('Help Desk/btnOKAddJob'))
} else {
// Element is not present; handle accordingly
WebUI.comment("Job is already added!")
}
Windows.click(findWindowsObject('Object Repository/Help Desk/pnMLV'))
I think my code is correct but I am getting an error instead of the method returning false.
Note: The actual window for winAddJob is not present, so the statement should return false.
Reason:
com.kms.katalon.core.exception.StepFailedException: Object ‘Object Repository/Help Desk/winAddJob’ is not present within 10 second(s)
Thank you very much for your topic! It may take a little while before Katalon team member or others forum members respond to you.
In the meantime, you can double-check your post to see if you can add any extra information i.e. error logs, HTML codes, screenshots, etc. Check out this posting guide to help us help you better!
But I cannot do a FailureHandling because if I’m not mistaken, it is an assert method, it would force the test case to fail. That is actually what I am trying to avoid in this scenario.
The verify in itself is like an assert, and if you don’t specify the argument regarding the FailureHandling part, it will use the default failureHandling behavior (that is specified in the settings). You only overwrite this behaviour by specifying the failureHandling in the verifyElement’s argument.
The FailureHandling.OPTIONAL would not fail your test, only cause a warning on the test step, but not affect the test case’s final status, it can still be passed.
But the waitForElementPresent is a good alternative.
// Use the waitForElementPresent() instead of the verifyElementPresent() then add FailureHandling.OPTIONAL
if (Windows.waitForElementPresent(findWindowsObject('Your Object'), 10, FailureHandling.OPTIONAL)) {
// Element is present; continue with your logic
WebUI.comment('Element present!')
} else {
// Element is not present; handle accordingly
WebUI.comment('Element not present!')
}
It is great to hear that your problem has been solved. Can you please help mark the solution and explain how you solve it so that others can leverage it? Thank you!1