[WebUI] Verify Element Present

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?

I created the following Test Case hoping that I could reproduce your problem.

import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

WebUI.openBrowser('')
WebUI.navigateToUrl("http://demoaut.katalon.com/")

TestObject tObj = new TestObject("Go To WRS/WRS choice")
tObj.addProperty('xpath', ConditionType.EQUALS,
	"//div[@id='stream-bg-2']/section[2]/ul/li[.//a[contains(@href, 'wrs')]]/a")

WebUI.verifyElementPresent(tObj, 10, FailureHandling.STOP_ON_FAILURE)

WebUI.closeBrowser()

The URL http://demoaut.katalon.com/ is different from your actual target, and the web page obviously does not have an HTML element point-able by the xpath. If your statement is right, this test case should pass. However, when I ran the test case, it failed with the following message:

Unable to find the element located by ‘By.xpath: //div[@id=‘stream-bg-2’]/section[2]/ul/li[.//a[contains(@href, ‘wrs’)]]/a’. Please recheck the objects properties to make sure the desired element is located.

The WebUI.verifyElementPresent keyword worked as documented. I could not reproduce your problem. I do not see why you have that problem.

Guys, use
WebUI.verifyTextNotPresent(‘put_the_text_of_the_message_here’, true, FailureHandling.STOP_ON_FAILURE).
To get the exact text, please use GetText.

Problem still exists when I use verifyElementPresent …if the element doesnt exist it doesnt return false

An element can be “present” without being displayed to the screen. The element can be hidden, yet it is in the page. Use “Review Source” to see if this is the case. To ensure an element is not hidden, you can also use, verifyElementVisible().

Using v. 8.2.5 - verifyElementPresent is logging an exception in the Console, even with “FailureHandling.OPTIONAL” as parameter.

It does return a true/false value properly, just prints a large exception/stacktrace into the Console.

I think the true meaning of this discussion is to “merely” see if an element is present or not.
The problem is that Katalon team don’t want to write such life saving method and wants to hang on to the “verifyElementPresent” which is already a misnomer for this discussion as no one wants to “verify” the element in the true sense: we just want the method to answer true/false and shut up: no exception to be thrown up because we dont want that- it’s not a true verification here.
TestObject tobj = some new test object()
if ( tobj.isPresent())
{
WebUI.click( tobj ) // we have out thing so, click
return // and move on
}
// this is the else: the obj is not there
WebUI.doSomethingElse()
doOtherStuff()
move on

There… my rant of the day…