How to use if/else statements

Hi there,

Im new at automation testing and I have a question for you.

I want to use if/else statements without know any code level, for example:

1- Sometimes on page have a word like ‘KATALON’
2- If system find ‘KATALON’ word on any level, run next step.
3- If system cannot find ‘KATALON’ than click next page.

here is my script but failed everytime

WebUI.click(findTestObject(‘Page/div_Search’))

if (true) {

WebUI.verifyTextPresent('KATALON', false)



WebUI.click(findTestObject('Page/div_KATALON'))



WebUI.click(findTestObject('Page/div_Continue'))

} else {

WebUI.click(findTestObject(‘Page/img’))

}

Thank you

Hi,

In which line the test fail? and what is the error message you have?

In my condition always if part executed, never goes to else and so ;when if condition fails program still search for elements in if condition and then fails obviously it wont find those elements on page -
below is my code-
"
String string_MatchRecords = WebUI.getText(findTestObject(‘Object Repository/Approce Application_GOAMTCH/total_records’))

	println(string_MatchRecords)

	String match_record = string_MatchRecords.substring(string_MatchRecords.lastIndexOf("/")+1);
	println(match_record)
	if (match_record>1)

	{
		WebUI.delay(2)

		WebUI.click(findTestObject('Object Repository/Approce Application_GOAMTCH/create_new'))
		WebUI.click(findTestObject('Object Repository/Approce Application_GOAMTCH/generateID_okButton'))
	}
	else{
		WebUI.delay(3)
		WebUI.click(findTestObject('Object Repository/Approce Application_GOAMTCH/createAsNew_yes'))
		//WebUI.click(findTestObject('Object Repository/Approce Application_GOAMTCH/create_yes_button'))
		WebUI.delay(1)
		WebUI.click(findTestObject('Object Repository/Approce Application_GOAMTCH/generateID_okButton'))
	}

"