verifyElementVisible and verifyElementPresent not working with new 5.8.3 version


#1

Hey guys,

I have updated new version of katalon to 5.8.3.
I have a requirement like if the element is present or visible then do some operations if it’s not visible or present then leave it.

I’m using the following methods of WebUI verifyElementPresent and **verifyElementVisible.
**
Problem: if an element is not present or visible then it throws an exception rather then return false.
Console log

10-27-2018 11:15:12 AM - [FAILED] - Web element with id: 'Object Repository/Checkout/Billing Address/Address Line 3' located by 'By.xpath: //div[@id="userAddress3"][count(. | //div[@id = 'userAddress3']) = count(//div[@id = 'userAddress3'])]' not found
10-27-2018 11:15:12 AM - [FAILED] - Unable to verify object 'Object Repository/Checkout/Billing Address/Address Line 3' is visible (Root cause: Web element with id: 'Object Repository/Checkout/Billing Address/Address Line 3' located by 'By.xpath: //div[@id="userAddress3"][count(. | //div[@id = 'userAddress3']) = count(//div[@id = 'userAddress3'])]' not found)

My code looks like this

if (WebUI.verifyElementVisible(findTestObject('Object Repository/Address Line 3'))) {
    def addressLine3 = WebUI.getText(findTestObject('Object Repository/Address Line 3'))
    WebUI.verifyMatch(addressLine3, findTestData('User Information/User Addresses').getValue('AddressLine3', 1), false)
}
if (WebUI.verifyElementPresent(findTestObject('Object Repository/User Country'), 1)) {
    def country = WebUI.getText(findTestObject('Object Repository/User Country'))
    WebUI.verifyMatch(country, findTestData('User Information/User Addresses').getValue('Country', 1), false)
}

if element not found then it will must return false.
thanks!


#2

hello, to supress exceptions, you need to set Failure handling in functions calls:

WebUI.verifyElementPresent(null, 0, FailureHandling.OPTIONAL)WebUI.verifyElementVisible(null, FailureHandling.OPTIONAL)


#3

Hi @Andrej_Podhajsky,

Hope you are doing good.

Why we need to add FailureHandling for returning false? Actual method should return false right?

Please help


#4

Correct @Sudheer_D_J
The FailureHandling is the optional parameter for the keyword.it should return false if the element not visible or present.


#5

yes, but if script will not find element it will throw an exception which, if not served, will stop any execution


#6

i also facing the same issue. i disappointed that it is throwing exception. This Must return false


#7

Same issue here as well. Suppressing the exception does not help. I need the method to return false so the script can continue to the “else” clause.


#8

Can you can use waitForElementVisible/Present? It will return true/false if the element is visible/present or not.


#9

Present doesn’t help me because the element is always present. I need to know when it’s visible. I actually just ended up doing a try/catch block to catch the exception and apply the “not visible” logic at that point. Seems to work fine for what I need at this point.