[WebUI] Verify Element Present

This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/webui-verify-element-present.html

The signature of this method says it returns a Boolean, either if the element is present or not.

According with my tests, a Boolean true is returned if the element is present which is the positive case, but if the element is not present, it always throws an exception (StepFailedException), so never returns false. This is a contradiction with the method documentation.

On the other hand I think the natural behaviour of the method would be as it documents (return true in case of present and return false in case it’s not present), and let the tester decide if to throw an exception or not in case of a false return.

Sumarizing: I think there is a bug in this method because

  1. It does not follow what its documentation promises
  2. The normal (or expected) behaviour for verify… methods should be to return true or false (and let the tester decide whether to raise an exception or not once the method has returned)
  3. Raise an exception only in case of an exceptional event, for example when the passed test object does not exists in the Object Repository

I don’t know if all other verify… methods have the same behaviour like this.

I would like to listen the community what others think about what should be the normal / expected behaviour of this metiod and other similar ones.

Indeed, I’ve seen that method KeywordUtil.markFailed() always raises an exception (StepFailedException), so I think when you write a custom keyword, there is no way to return from a method, markind it as failed: you always raises an exception.

¿ Is this behaviour the most appropriated ?

(perhaps this is the root cause why verifyElementPresent raises an exception in the negative case)

Hello Team katalon,

This method is not working as expected. This is returning “true” even when the webelement is not present.
Please let me know, if there is any alternate solution to this.

@Madhu.basavaraja @Enrique_Castilla
Hello Team Katalon,

I have the same problem: this method isn’t working as expected. It’s returning “true” even when the webelement is not present.

Please let’s me know, if there is any alternate solution to this case.

Best regards,

@Katalon Developers : Would be able to provide update on this. When can we expect fix on this ?

All the verify methods have the same behavior for negative cases, it throws exception instead of returning boolean false, when the verify statement fails.

Hi @Enrique_Castilla, @Madhav_Choudhary, @Madhu.basavaraja

Please try with this workaround solution:

WebUI.verifyElementPresent(findTestObject(''), timeout, FailureHandling.OPTIONAL)

We will update this fix in v6.4.0.


Hi Everyone, the method returns True and False on the presence and absence of an element respectively. However, it also throws the StepFailedException if the element is absent (which should be mentioned in the documentation). In order to overcome this problem, we have to set the Failure Handling to optional by passing third argument. Therefore, the method would be
WebUI.verifyElementPresent(findTestObject(‘someobject’, timeout, FailureHandling.OPTIONAL)

This would definitely work!!!

How is the verifyElementPresent used in katalon recorder?

@Fernando_Espinoza this topic is about katalon studio. for the recorder kindly use the dedicated topics and look for the dedicated documentation.

We are using 7.0.6, but still having this issue, below method doesn’t help, please advise.

WebUI.verifyElementPresent(findTestObject(‘someobject’, timeout, FailureHandling.OPTIONAL)

I’m using 7.0.7 and facing the same issue with WebUI.verifyElementNotPresent.
e.g. for an object I know is present in the dom, the step for WebUI.verifyElementPresent correctly passes. I expect that WebUI.verifyElementNotPresent for the same object fails but it’s not the case:

It’s all marked green.

Hi @DianaF,

Please update to v7.0.10, we have fixed this issue.

Thank you so much! I updated to 7.0.10 and it works again as expected! :smile: