Few steps of If statement is getting executed in else statement

Hi,
I am trying to execute if else statement and few of the steps that are mandatory in if statement are getting executed in else statement even thought the steps are not present in else statement.
Please help me in understanding where the issue is.

TestData excelData = findTestData('Data Files/ExcelDataSource/GroupProductTestData')


WebUI.waitForElementClickable(findTestObject('Group Product/Group Order_Hyperlink/Group Products0'), GlobalVariable.TimeOut)

WebUI.click(findTestObject('Group Product/Group Order_Hyperlink/Group Products0'))

WebUI.click(findTestObject('Group Product/New Button/New_GP_Button'))

WebUI.waitForPageLoad(GlobalVariable.TimeOut)

WebUI.waitForElementVisible(findTestObject('Group Product/Facets Benefit Selector/Product Type'), GlobalVariable.TimeOut)

WebUI.selectOptionByValue(findTestObject('Object Repository/Dump/Page_Salesforce - Unlimited Edition/select_- None -MedicalSpecialt'), 
    excelData.getValue('Product Type', index), true)

WebUI.delay(3)

WebUI.selectOptionByValue(findTestObject('Object Repository/Dump/Page_Salesforce - Unlimited Edition/select_- None -PortfolioCustom'), 
    excelData.getValue('Benefit Complexity', index), false)

WebUI.delay(3)

//Begin If Condition, if Benefit Type = ASO

def asoBenefitType = WebUI.getText(findTestObject('Object Repository/Dump/Page_Salesforce - Unlimited Edition/select_- None -PortfolioCustom'))

if(asoBenefitType.contains('ASO') == true) {
	
	WebUI.selectOptionByValue(findTestObject('Object Repository/Group Product/ASO_FBS/FBS_ASO_Type/ASO_Type'), excelData.getValue('Type', index), true)
	
	WebUI.delay(3)

	WebUI.setText(findTestObject('Object Repository/Group Product/ASO_FBS/FBS_ASO_PlanName/ASO_PlanName'), excelData.getValue('Plan Name', index), FailureHandling.STOP_ON_FAILURE)
	
	WebUI.delay(2)
	
	WebUI.sendKeys(findTestObject('Object Repository/Group Product/ASO_FBS/FBS_ASO_PlanName/ASO_PlanName'),
		Keys.chord(Keys.DOWN, Keys.ENTER))
	
	WebUI.delay(2)
	
	WebUI.click(findTestObject('Group Product/FBS_1st Page/Continue_GP_Button'))
	
	WebUI.waitForPageLoad(GlobalVariable.TimeOut)
	
	WebUI.delay(3)
	
	WebUI.setText(findTestObject('Group Product/RX Plan Field/RX Plan'), excelData.getValue('RX Plan', index), FailureHandling.STOP_ON_FAILURE)
	
	WebUI.delay(3)
	
	WebUI.sendKeys(findTestObject('Group Product/RX Plan Field/RX Plan'), Keys.chord(Keys.DOWN, Keys.ENTER))
	
	WebUI.click(findTestObject('Group Product/FBS_Page2/Continue_GP2_Button'))
	
	WebUI.click(findTestObject('Group Product/FBS_Page3_Save/Save_GP3_Button'))
	
	WebUI.waitForPageLoad(GlobalVariable.TimeOut)
	
	//Edit Group Product Page for ASO
	
	WebUI.click(findTestObject('Object Repository/Group Product/ASO_FBS/Edit Button_ASO GP'))
		
	def stockID1 = excelData.getValue('Stock', index)
	//def stockID = '1000000100  DMHC PPO'
	
	WebUI.sendKeys(findTestObject('Object Repository/Group Product/Group Product Edit Page Details/Group Product Edit Page/input_Stock_GP'),
		stockID1)
	
	WebUI.click(findTestObject('Object Repository/Group Product/Group Product Edit Page Details/Group Product Edit Page/GP_Stock_lookupIconOn'))
	
	
	/*WebUI.switchToWindowTitle('Group Product Edit: GP-667972 ~ Salesforce - Unlimited Edition')*/
	
	WebUI.switchToWindowIndex(1)
	
	WebUI.delay(2)
	
	StockID_CODE1 = WebUI.modifyObjectProperty(findTestObject('Object Repository/Group Product/DHMC_PPO_object/a_1000000100  DMHC PPO'),
		'text', 'equals', stockID1, true)
	
	WebUI.waitForElementClickable(StockID_CODE1, 7, FailureHandling.OPTIONAL)
	
	WebUI.click(StockID_CODE1)
	
	WebUI.switchToWindowIndex(0)
	
	WebUI.delay(2)
	
	WebUI.selectOptionByValue(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/GP_ID Card Format Control_ASO'),
		 excelData.getValue('ID Card Format Control ID', index), true)
	
	WebUI.selectOptionByValue(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/GP_ID Card Type_ASO'),
		excelData.getValue('ID Card Type', index), true)
	
	WebUI.selectOptionByValue(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/GP_DOIDHMC_ASO'),
		excelData.getValue('DOI/DMHC/Group Specific', index), true)
	
	WebUI.selectOptionByValue(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/GP_Plan Type_ASO'),
		excelData.getValue('Plan Type', index), true)
	
	WebUI.selectOptionByValue(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/GP_Network Set_ASO'),
		excelData.getValue('Network Set', index), true)
	
	WebUI.selectOptionByValue(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/GP_Prefix_ASO'),
		excelData.getValue('Prefix', index), true)
	
	//RX Discount Guarantee Section
	
	WebUI.setText(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/AWP-Brand Retail'), excelData.getValue('AWP-Brand Retail', index), FailureHandling.CONTINUE_ON_FAILURE)
	
	WebUI.setText(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/AWP-Brand Mail'), excelData.getValue('AWP-Brand Mail', index), FailureHandling.CONTINUE_ON_FAILURE)
	
	WebUI.setText(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/AWP-Brand Specialty'),
		excelData.getValue('AWP-Brand Specialty', index), FailureHandling.CONTINUE_ON_FAILURE)
	
	WebUI.setText(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/Dispense Fee-Brand Retail'),
		excelData.getValue('Dispense Fee-Brand Retail', index), FailureHandling.CONTINUE_ON_FAILURE)
	
	WebUI.setText(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/Dispense Fee-Brand Mail'),
		excelData.getValue('Dispense Fee-Brand Mail', index), FailureHandling.CONTINUE_ON_FAILURE)
	
	WebUI.setText(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/Dispense Fee-Brand Speciality'),
		excelData.getValue('Dispense Fee-Brand Specialty', index), FailureHandling.CONTINUE_ON_FAILURE)
	
	WebUI.setText(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/AWP-Generic Retail'), excelData.getValue('AWP-Generic Retail', index), FailureHandling.CONTINUE_ON_FAILURE)
	
	WebUI.setText(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/AWP-Generic Mail'), excelData.getValue('AWP-Generic Mail', index), FailureHandling.CONTINUE_ON_FAILURE)
	
	WebUI.setText(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/AWP-Generic Specialty'),
		excelData.getValue('AWP-Generic Specialty', index), FailureHandling.CONTINUE_ON_FAILURE)
	
	WebUI.setText(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/Dispense Fee-Generic Retail'),
		excelData.getValue('Dispense Fee-Generic Retail', index), FailureHandling.CONTINUE_ON_FAILURE)
	
	WebUI.setText(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/Dispense Fee-Generic Mail'),
		excelData.getValue('Dispense Fee-Generic Mail', index), FailureHandling.CONTINUE_ON_FAILURE)
	
	WebUI.setText(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/Dispense Fee-Generic Speciality'),
		excelData.getValue('Dispense Fee-Generic Specialty', index), FailureHandling.CONTINUE_ON_FAILURE)
	
	WebUI.click(findTestObject('Object Repository/Group Product/Group Product Edit Page Details/Group Product Edit Page/Save_GP Edit Button'))
	
	// End If Condition for ASO
} else 
//if (asoBenefitType.contains('Portfolio') == true) 
{

WebUI.selectOptionByValue(findTestObject('Object Repository/Dump/Page_Salesforce - Unlimited Edition/select_- None -HMOPOSPPOPSPTan'), 
    excelData.getValue('Type', index), true)

WebUI.delay(3)

WebUI.setText(findTestObject('Object Repository/Dump/Page_Salesforce - Unlimited Edition/input_(Reloading)_FacetsBenefi'), 
    excelData.getValue('Plan Name', index), FailureHandling.STOP_ON_FAILURE)

WebUI.delay(2)

WebUI.sendKeys(findTestObject('Object Repository/Dump/Page_Salesforce - Unlimited Edition/input_(Reloading)_FacetsBenefi'), 
    Keys.chord(Keys.DOWN, Keys.ENTER))

WebUI.delay(2)

WebUI.click(findTestObject('Group Product/FBS_1st Page/Continue_GP_Button'))

WebUI.waitForPageLoad(GlobalVariable.TimeOut)

WebUI.delay(3)

WebUI.setText(findTestObject('Group Product/RX Plan Field/RX Plan'), excelData.getValue('RX Plan', index), FailureHandling.STOP_ON_FAILURE)

WebUI.delay(3)

WebUI.sendKeys(findTestObject('Group Product/RX Plan Field/RX Plan'), Keys.chord(Keys.DOWN, Keys.ENTER))

WebUI.delay(2)

WebUI.click(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Details_ASO/GP_Shield Support_Radiobutton'), FailureHandling.CONTINUE_ON_FAILURE)

//VBB Section Start

/*WebUI.click(findTestObject('Object Repository/Group Product/GP_ASO/Group Product Details_ASO/GP_Diabetes_Radiobutton'))*/

//VBB Section End
WebUI.click(findTestObject('Group Product/FBS_Page2/Continue_GP2_Button'))

WebUI.click(findTestObject('Group Product/FBS_Page3_Save/Save_GP3_Button'))

WebUI.waitForPageLoad(GlobalVariable.TimeOut)

WebUI.click(findTestObject('Object Repository/Group Product/Group Product Edit Page Details/Group Product Edit Button/GP_Edit Button'))

def stockID = excelData.getValue('Stock', index)
//def stockID = '1000000100  DMHC PPO'

WebUI.sendKeys(findTestObject('Object Repository/Group Product/Group Product Edit Page Details/Group Product Edit Page/input_Stock_GP'), 
    stockID)

WebUI.click(findTestObject('Object Repository/Group Product/Group Product Edit Page Details/Group Product Edit Page/GP_Stock_lookupIconOn'))


/*WebUI.switchToWindowTitle('Group Product Edit: GP-667972 ~ Salesforce - Unlimited Edition')*/

WebUI.switchToWindowIndex(1)

WebUI.delay(2)

StockID_CODE = WebUI.modifyObjectProperty(findTestObject('Object Repository/Group Product/DHMC_PPO_object/a_1000000100  DMHC PPO'), 
    'text', 'equals', stockID, true)

WebUI.waitForElementClickable(StockID_CODE, 7, FailureHandling.OPTIONAL)

WebUI.click(StockID_CODE)

WebUI.switchToWindowIndex(0)

WebUI.delay(2)

WebUI.selectOptionByValue(findTestObject('Object Repository/Group Product/Group Product Edit Page Details/Group Product Edit Page/GP_ID Card Format Control ID'), 
    excelData.getValue('ID Card Format Control ID', index), true)

WebUI.selectOptionByValue(findTestObject('Object Repository/Group Product/Group Product Edit Page(2)/ID Card Type(2)'), 
    excelData.getValue('ID Card Type', index), true)

WebUI.selectOptionByValue(findTestObject('Object Repository/Group Product/Group Product Edit Page Details/Group Product Edit Page/GP_DOIDHMCGroup Specific'), 
    excelData.getValue('DOI/DMHC/Group Specific', index), true)

WebUI.selectOptionByValue(findTestObject('Object Repository/Group Product/Group Product Edit Page Details/Group Product Edit Page/GP_Plan Type'), 
    excelData.getValue('Plan Type', index), true)

WebUI.selectOptionByValue(findTestObject('Object Repository/Group Product/Group Product Edit Page Details/Group Product Edit Page/GP_Network Set'), 
    excelData.getValue('Network Set', index), true)

WebUI.selectOptionByValue(findTestObject('Object Repository/Group Product/Group Product Edit Page Details/Group Product Edit Page/GP_Prefix'), 
    excelData.getValue('Prefix', index), true)

WebUI.click(findTestObject('Object Repository/Group Product/Group Product Edit Page Details/Group Product Edit Page/Save_GP Edit Button'))
}

All the steps in the //RX Discount Guarantee Section starts executing after this step in else statement

WebUI.selectOptionByValue(findTestObject('Object Repository/Group Product/Group Product Edit Page Details/Group Product Edit Page/GP_Prefix'), 
    excelData.getValue('Prefix', index), true)

Are you using Katalon Studio Enterprise edition, or a version prior to 7.x.x? If so, you can place a breakpoint in your if/else statement, run in debug, and see where the execution flow is going.

Just looking at your code, I can’t see why it would jump back to the if block.

This might be the issue ? If Statement line is commented out

My organization uses Katalon 6.1.5 version. If I update the Failure Handling as STOP_ON_FAILURE, my test case fails.

This is the error I get

Test Cases/TestCase Division/TestCases - All FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to set text ‘’ of object ‘Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/AWP-Brand Retail’ (Root cause: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Group Product/GP_ASO/Group Product Edit Page_ASO/AWP-Brand Retail’ located by ‘By.xpath: //input[@id = ‘00N1B00000BTCRM’ and @type = ‘text’]’ not found)
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:36)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:27)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword.setText(SetTextKeyword.groovy:65)
at com.kms.katalon.core.webui.keyword.builtin.SetTextKeyword.execute(SetTextKeyword.groovy:37)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.setText(WebUiBuiltInKeywords.groovy:936)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$setText$9.call(Unknown Source)
at Group Product - TC.run(Group Product - TC:125)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword$_callTestCase_closure1.doCall(CallTestCaseKeyword.groovy:59)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword$_callTestCase_closure1.call(CallTestCaseKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:54)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword.callTestCase(CallTestCaseKeyword.groovy:80)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword.execute(CallTestCaseKeyword.groovy:44)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.keyword.BuiltinKeywords.callTestCase(BuiltinKeywords.groovy:334)
at TestCases - All.run(TestCases - All:26)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1576522752128.run(TempTestCase1576522752128.groovy:22)

I’m wondering if Katalon is failing to save properly (does happen).

  1. Close all test cases.
  2. Right click on Test Cases in Tests Explorer.
  3. Click Refresh.

image

When you reopen the test case, check the code and test again.

Have you tried running in debug mode?