How to verify boolean condition in if statement

Boolean visible = WebUI.verifyElementVisible(findTestObject(‘BuyingAccessoy_Inputs/saveTheAddres’))

if (visible == true) {

WebUI.click(findTestObject('BuyingAccessoy_Inputs/clickAddressBox'))



WebUI.click(findTestObject('BuyingAccessoy_Inputs/selectTheAddress'))



WebUI.click(findTestObject('BuyingAccessoy_Inputs/saveTheAddres'))

}

else

{

println (‘address already present’)

}

Note : BuyingAccessoy_Inputs/saveTheAddres element is not visible , but it is not executing the else statement…please help me … thanks in advance

if(visible) // visible is allready a boolean
verifyElementVisible throws an exception if it’s not handeled, it will stop any execution (even if will not be evaluated) so, to get aroud, use

WebUI.verifyElementVisible(findTestObject('BuyingAccessoy_Inputs/saveTheAddres'), FailureHandling.OPTIONAL)
1 Like