I want to use catch block in case that some of tests fail so my code snippet is like below
try {
‘Wait username field to become visible’
WebUI.waitForElementVisible(findTestObject(‘Page_Login/input_loginComponentj_username’), GlobalVariable.timeout)'Type username' not_run: WebUI.sendKeys(findTestObject('Page_Login/input_loginComponentj_username'), GlobalVariable.ceoUsername.toString().concat( '##').concat(GlobalVariable.loginname)) 'Type username' WebUI.sendKeys(findTestObject('Page_Login/input_loginComponentj_username'), 'scosic##npalikuca') 'Type password' WebUI.sendKeys(findTestObject('Object Repository/Page_ERP 3.0/input_Password_loginComponentj'), GlobalVariable.password) 'Click on Login button' WebUI.click(findTestObject('Object Repository/Page_ERP 3.0/span_Login')) 'Wait home form to be visible' WebUI.waitForElementVisible(findTestObject('Page_Home/HomeForm'), GlobalVariable.timeout, FailureHandling.CONTINUE_ON_FAILURE) 'Logout' WebUI.click(findTestObject('Page_Login/span_Logout'), FailureHandling.CONTINUE_ON_FAILURE) } catch (Exception e) { println 'Exception caught ' + e.printStackTrace() }
Test fails within try block but catch block is not executed. Anyone has an idea what is wrong with my code?