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!