FailureHandling.CONTINUE_ON_FAILURE is not showing red in log

Hi, i want to ask about Failure Handling. From my experience using it for the past 1 year, i remember it correctly that there are 3 types of FailureHandling.

  1. CONTINUE_ON_FAILURE : The process is still running, but the log will be red because of the failure.
  2. OPTIONAL : The process is still running, but the log will be warning (yellow) and its not detected by “Show the previous failure” button.
  3. STOP_ON_FAILURE : The process is stop and shows error.

I used CONTINUE_ON_FAILURE and it shows green, but when i clicked it, the right light is showing me red. Its not detected by the button too.

If i see this, my If Verify is an error but its green in the log. In the detail itself, its red but it shows my else if is correct (present at this point).

From what i remember, 5 is supposed to be red. Am i wrong ?

1 Like

Can you try an experiment? Copy your “verifyElementPresent” statement and paste it on the line above your if statement and see if it performs the way you expect, which I believe it will. However, in your if statement, whatever the boolean value “verifyElementPresent” is returning, is equivalent to false.

WebUI.verifyElementPresent(findTestObject('...'), 3, FailureHandling.CONTINUE_ON_FAILURE)

if (WebUI.verifyElementPresent(findTestObject('...'), 3, FailureHandling.CONTINUE_ON_FAILURE) {

It may be because your code is too fast and the object is not present when you “test” for its presence, or you may not have the “timeOut” value set large enough for your network. These are things that you should find out.
Edit: since you do a “click” just above your “if verifyElementPresent” statement, perhaps you should add a wait statement before you test for its presence.

WebUI.waitForPageLoad(10)
WebUI.waitForElementVisible(findTestObject('...'), 10)
WebUI.waitForElementPresent(findTestObject('...'), 10)
1 Like

I think, you are wrong.

1 Like

I think you should NOT use the verifyElementPresent keyword in the condtion expression of if (condition) statement. That will confuse you.

If you use the verifyElementPresent keyword at the top-level, like

4 WebUI.clickfindTestObject("Main Application/button_ok")
5 WebUI.verifyElementPresent("Main Application/Level Contract/text_infoLog", 3, 
        STOP_ON_FAILURE)
...

then, I guess, you would see a :x: for the line No.5.

However, in the original code, you put the call to verifyElementPresent inside the if (condition) clause. In this case, the conditon was evaluated to be false successfully, so the if clause worked fine without throwing an Exception. Therefore the statement No.5 will have no :x: .

1 Like

I personally use WebUI.verifyElementPresent() keyword only with FAILURE_HANDLING.STOP_ON_FAILURE.

I never use the WebUI.verifyElementPresent() keyword with CONTINUE_ON_FAILURE or OPTIONAL because I do not undertstand the meaning: how the keyword would or should work. To me, the name verify* with the CONTINUE_ON_FAILURE option looks just nonsence. I would rather argue that all of verify* commands should stop the processing immediately when a failure of finding an HTML element occured.

In a case where I expect a HTML element to be found missing occasionally, I will use WebUI.waitForElementPresent() keyword with the CONTINUE_ON_FAILURE or OPTIONAL because the name waitFor* makes sense to me with these options associated.

If I were you, I would rather writte as follows:

4 WebUI.clickfindTestObject("Main Application/button_ok")
5 boolean result = WebUI.waitForElementPresent("Main Application/Level Contract/text_infoLog", 3, CONTINUE_ON_FAILURE)
6 if (result) {
      /* when found */
      KeywordUtil.logInfo("everything is fine")
  else {
      /* when not found */
      KeywordUtil.markFailed("text_infoLog is not found")
  }

See KeywordUtil (Katalon Studio API Specification) for the KeywordUtil class.

What’s the difference between WebUI.verifyElementPresent() and waitForElementPresent() ?

See the following dicsussion:

1 Like

I see. It might be my code is not having big time on timeout. It make sense right now. I already tried it and it worked perfectly.

This is a great tips. It realize me the purpose of the verify. I will remember this.

1 Like

May i ask about this ?
I have some cases that verifying page after the button is clicked, which i don’t have the exact time for the timeout (loading, lagging, etc)

Is it possible to use visible, then present ? Or is it redundant to use both ?

Visible doesn’t have timeout, so check with it first until its red (probably 1 minute checking with the system), then present with timeout.

1 Like

I would rather use verifyElementPresent with some timeout value first, then verifyElementVisible if necessary.

It depends on how your Application Under Test works.

If your AUT has an HTML Element present in the DOM wtih the CSS visibility property of hidden occasionally on load, then it is reasonable to use the verifyElementPresent with timeout first. Then use the verifyElementVisible to check its visibility.

Though I personally have never seen such a tricky AUT.

In case you are sure that the target HTML element does NOT have CSS visibility of “hidden”, then a single call to verifyElementPresent() with appropriate timeout would be sufficient to check its presence and its visiblity.