This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/webui-verify-element-present.html
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
- It does not follow what its documentation promises
- 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)
- 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.
Thanks
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!!!
Hi
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!
Iām using 7.2.6 and facing the same issue with WebUI.verifyElementNotPresent.Kindly help me
Hello there,
Iām using version 7.2.1 and still facing the same issue. Currently Iām applying the work around mentioned in the chain. The output for the verifyElementPresent or verifyElementVisible is not true or false and hence unable to use them in If Else statement. Kindly advise.
Appreciate your help.
-Gowri
Could you println the output? It should be true or false.
Is there any way to suppress the errors logged by Katalon when an element isnāt found? For example, if an element exists I want to do A, otherwise B.
if (WebUI.verifyElementPresent(element, timeOut, FailureHandling.OPTIONAL) {
A
} else {
B
}
If āelementā is not found, Iāll get a garbage readout like:
Unable to find the element located by āBy.xpath: //span[@class=āelement-xpathā]ā. Please recheck the objects properties to make sure the desired element is located.
Is there a better way to check for elements or mute these āerrorsā?
Iām unable to print output in the console
PLS Have a look at