[WebUI] Verify Element Present

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:
pass

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:

1 Like

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

@kyilmaz

PLS Have a look at

1 Like

the issue is still present on 7.4.3. The thing is verifyElementPresent should return false when element is not present, and not giving an exception. Additionally to that, it seems that it is not possible to manage the exception using try/catch neither so, it’s a huge problem!

1 Like

I am using Katalon 7.7.2 today. This command has not suppressed the warning log yet.
WebUI.verifyElementPresent(${testObject}, 1, FailureHandling.OPTIONAL)

2020-11-13 18:13:38.157 ERROR c.k.k.core.keyword.internal.KeywordMain  - ❌ Unable to click on object '${testObjectValue}' (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to click on object '${testObjectValue}'
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.click(ClickKeyword.groovy:76)
	at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:43)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:617)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$4.call(Unknown Source)

any solution please?

Looks like its solved in 7.8.2 :slight_smile:

I am using the same version 7.8.2 but issue still exists.
Hello Team katalon, @Katalon_team

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.

i am using version 7.9.1 and the issue still exist. how come for you it is working?

Hi,
my problem is that Katalon considers that an object is present into the page even if this object does not exist. I’m using Katalon version 7.9.1.

In particular I defined an object called “Go To WRS/WRS choice” using this xpath:

//div[@id='stream-bg-2']/section[2]/ul/li[.//a[contains(@href, 'wrs')]]/a

and I defined a test case that includes the following step:

WebUI.verifyElementPresent(findTestObject('Go To WRS/WRS choice'), 10, FailureHandling.STOP_ON_FAILURE)

When I run the test, Katalon consider this object as present even if it is not.
I tried also to use verifyElementVisible and verifyElementClickable methods, but with the same results.
I also checked the xpath using the Chrome console and it works fine both with elements present and with element not present in the page.

My aim is to obtain the failure if the element is not present.

Any suggestion?