verifyElementVisible is not working in If statement



I am using verifyElementVisible in If statement but it does not work if object if object is not present.

def errorMsg1 = Mobile.verifyElementVisible(findTestObject(‘Object Repository/LMO_LoginPg/ErrorMessage1’), 5)

if (errorMsg1 == true)


Mobile.tap(findTestObject(‘Object Repository/LMO_LoginPg/ErrorMessage1’), 5)



CustomKeywords.‘writeDataToExcel.WriteDataToExcelSheet.WriteDatatoDataFile’(username, 3)

Mobile.takeScreenshot(‘C:\\Alok\\KatalonStudio_LMO\\LMO\\Test Cases\\Screenshots\\Login_LoginSuccssful.png’)


When object ‘Object Repository/LMO_LoginPg/ErrorMessage1’ is not visible, the code does not go to else part. It shows error message.
Error message:-
Test1 FAILED because (of) Failed to check for element 'Object Repository/LMO_LoginPg/errorMsg1 ’ visible (Root cause: Element 'Object Repository/LMO_LoginPg/errorMsg1 ’ not found)

Can someone tell me whether I have missed anything here and reason for getting this message?


It looks like you need to modify the default failure handling (third argument to verifyElementVisible).

Set it to Optional.


Thanks, It is working for me