Decision-Making Statements
As the name suggests, these statements are used to make decisions based on the conditions provided. Conditions are set using the following relational operators.

The statements are if, else, else-if, switch, case and default.
-
The if statement executes its set of steps if the boolean result it receives according to the specified condition is true.
-
Using else-if after the if statement helps include multiple conditions. The else statement concludes the if and consecutive else-if statements.
-
Execution of the else block of steps occurs if the conditions of if and else-if are false.
-
The Switch statement encloses one or more Case statements executed based on whether there is a match with the expression/input value mentioned in the switch statement.
-
All Case statements have a break statement to mark their end.
- The Default statement is executed only when none of the Case statements is executed.
Manual View
Step 1: In the Manual view, open a test case and click Add. Select Decision-making Statements.
Step 2: Select a statement and click on Add to add keywords under the statement.

Script View
The Script View involves programming to use decision control statements. It uses Groovy or Java language to implement if-else and switch case statements. Here are some examples.
If-Else Example
if (true) {
WebUI.click(findTestObject('Page_ModifySheet/btn_createSheet'), FailureHandling.STOP_ON_FAILURE)
}
else if (true) {
WebUI.click(findTestObject('Page_ModifySheet/btn_updateSheet'), FailureHandling.OPTIONAL)
}
else {
WebUI.click(findTestObject('Page_ModifySheet/btn_deleteSheet'), FailureHandling.STOP_ON_FAILURE)
}
Switch Case Example
switch (true) {
case true: WebUI.click(findTestObject('Page_ModifySheet/btn_createSheet'), FailureHandling.STOP_ON_FAILURE)
break
case true: WebUI.click(findTestObject('Page_ModifySheet/btn_updateSheet'), FailureHandling.OPTIONAL)
break
default: WebUI.click(findTestObject('Page_ModifySheet/btn_deleteSheet'), FailureHandling.STOP_ON_FAILURE)
break }
Frequently Asked Questions
What is FailureHandling?
It is an optional parameter that defines the action to be performed in case of a failure. There are three options for Failure Handling in Katalon - Stop on Failure, Continue on Failure and Optional.
What kind of comparisons can the Switch statement support?
Switch statements support matches with regular expressions, instances of classes and collection case values where the switch value is present in the collection.
Differentiate between the Manual and Script view in Katalon.
The Manual view allows a user to use basic keyword-driven configuration to create automated tests without writing code. The Script view is mostly used by advanced users or programmers who can modify and write test scripts using Groovy or Java.
Conclusion
This blog discusses decision-making statements in Katalon Studio. It explains adding statements like if, else-if and switch in the Manual and Script View. Check out our articles on Generate Test Steps in Manual and Script View, Sample API tests project in Katalon and Sample Cucumber test project in Katalon. It explains how to create test steps in each view with an example. Explore our Library on Coding Ninjas Studio to gain knowledge on Data Structures and Algorithms, Machine Learning, Deep Learning, Cloud Computing and many more! Test your coding skills by solving our test series and participating in the contests hosted on Coding Ninjas Studio! Looking for questions from tech giants like Amazon, Microsoft, Uber, etc.? Look at the problems, interview experiences, and interview bundle for placement preparations. Upvote our blogs if you find them insightful and engaging! Happy Coding!
