{"id":72,"date":"2025-09-06T09:10:51","date_gmt":"2025-09-06T09:10:51","guid":{"rendered":"https:\/\/blog.kerjarapi.com\/?p=72"},"modified":"2025-09-06T09:11:34","modified_gmt":"2025-09-06T09:11:34","slug":"katalon-studio-test-case-mark-as-passed-failed-and-failure-handling-in-manual-view-and-script-view","status":"publish","type":"post","link":"https:\/\/blog.kerjarapi.com\/?p=72","title":{"rendered":"Katalon Studio Test Case &#8211; Mark as Passed\/Failed and Failure Handling (in Manual View and Script View)"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>In katalon Studio, to have more control over our Test Case, we are able to mark our Test Case as \u201cPassed\u201d or \u201cFailed\u201d. Another option, there\u2019s a method in Katalon Studio called Failure Handling. As the name implies, it is used to tell Katalon Studio how to handle a failure, meaning if our test step has failed to execute or has encountered an error. \u201cMark as Passed\/Failed\u201d and \u201cFailure Handling\u201d are used to have more control over our Test Cases, here\u2019s how.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Marking our Test Case as Passed or Failed<\/h2>\n\n\n\n<p>To mark our Test Case as Passed or Failed, we need to import the Keyword Util library, then using an if statement, if our Test Case meets a certain condition it will be marked as Passed or Failed. For example, we are trying to find if an element is present or not:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import com.kms.katalon.core.util.KeywordUtil\n\nif (WebUI.verifyElementPresent(findTestObject('Page_Home\/lbl_WelcomeMessage'), 10, FailureHandling.OPTIONAL)) {\n\t\/\/Mark Passed status after this step\n\tKeywordUtil.markPassed(\"Element is present\")\n} else {\n\t\/\/Mark Failed status after this step\n\tKeywordUtil.markFailed(\"Element is not present\")\n}\n<\/code><\/pre>\n\n\n\n<p>There\u2019s actually a third option, which is to mark the Test Case as a \u201cwarning\u201d. I have not used this, but I can show you how it works. It works just like before, you can use the syntax:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import com.kms.katalon.core.util.KeywordUtil\n\nKeywordUtil.markWarning(\"Reason for your warning\")\n\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Mark as Passed or Failed in Test Suite Reports<\/h2>\n\n\n\n<p>When we run Test Suites, we can generate the test result and saved it as PDF, CSV, or HTML. Let us see if we use \u201cMark as Passed\u201d, \u201cMark as Failed\u201d, or \u201cMark as Warning\u201d in our Test Case, how is the report going to be? Here are the Test Suite report screenshots:<\/p>\n\n\n\n<p>Test Suite report as CSV Summary file:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"877\" height=\"231\" src=\"https:\/\/blog.kerjarapi.com\/wp-content\/uploads\/2025\/09\/image-14.png\" alt=\"\" class=\"wp-image-73\" srcset=\"https:\/\/blog.kerjarapi.com\/wp-content\/uploads\/2025\/09\/image-14.png 877w, https:\/\/blog.kerjarapi.com\/wp-content\/uploads\/2025\/09\/image-14-300x79.png 300w, https:\/\/blog.kerjarapi.com\/wp-content\/uploads\/2025\/09\/image-14-768x202.png 768w\" sizes=\"auto, (max-width: 877px) 100vw, 877px\" \/><\/figure>\n\n\n\n<p>Test Suite report as HTML file:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"903\" height=\"917\" src=\"https:\/\/blog.kerjarapi.com\/wp-content\/uploads\/2025\/09\/image-1-4.png\" alt=\"\" class=\"wp-image-74\" srcset=\"https:\/\/blog.kerjarapi.com\/wp-content\/uploads\/2025\/09\/image-1-4.png 903w, https:\/\/blog.kerjarapi.com\/wp-content\/uploads\/2025\/09\/image-1-4-295x300.png 295w, https:\/\/blog.kerjarapi.com\/wp-content\/uploads\/2025\/09\/image-1-4-768x780.png 768w\" sizes=\"auto, (max-width: 903px) 100vw, 903px\" \/><\/figure>\n\n\n\n<p>Test Suite report as PDF file:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"516\" src=\"https:\/\/blog.kerjarapi.com\/wp-content\/uploads\/2025\/09\/image-2-3-1024x516.png\" alt=\"\" class=\"wp-image-75\" srcset=\"https:\/\/blog.kerjarapi.com\/wp-content\/uploads\/2025\/09\/image-2-3-1024x516.png 1024w, https:\/\/blog.kerjarapi.com\/wp-content\/uploads\/2025\/09\/image-2-3-300x151.png 300w, https:\/\/blog.kerjarapi.com\/wp-content\/uploads\/2025\/09\/image-2-3-768x387.png 768w, https:\/\/blog.kerjarapi.com\/wp-content\/uploads\/2025\/09\/image-2-3.png 1107w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>From the screenshots above we can see the difference in our report. Mark as Passed will be counted as a \u201cPassed\u201d step, \u201cMark as Failed\u201d will be counted as a \u201cFailed\u201d step, and \u201cMark as Warning\u201d will be counted as \u201cPassed\u201d and can only be seen as \u201cWarning\u201d in HTML report view. Now that we know how it is in our reports, we can use it as we see fit.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Failure Handling in Manual View and Script View<\/h2>\n\n\n\n<p>There are three types of Failure Handling in Katalon Studio, which are: Continue on failure, Stop on failure, and Optional. These are each of the syntaxes for example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>WebUI.verifyElementPresent(findTestObject('Page_Login\/btn_Login'), 10, FailureHandling.CONTINUE_ON_FAILURE)\n\nWebUI.verifyElementPresent(findTestObject('Page_Login\/btn_Login'), 10, FailureHandling.STOP_ON_FAILURE)\n\nWebUI.verifyElementPresent(findTestObject('Page_Login\/btn_Login'), 10, FailureHandling.OPTIONAL)\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Continue on Failure: This option allows the test case to continue running even if the step fails. It logs the failure but proceeds to the next step.<\/li>\n\n\n\n<li>Stop on Failure: This option stops the execution of the test case immediately when a step fails. It logs the failure and halts the test.<\/li>\n\n\n\n<li>Optional: This option marks the step as optional. The test case will continue whether the step passes or fails, and the result of this step won\u2019t affect the final status of the test.<\/li>\n\n\n\n<li><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Failure Handling and Loops<\/h2>\n\n\n\n<p>Loops and Failure Handling can be combined, as long as the Failure Handling method can return a boolean value. For example when using verification methods, we type in:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>while(WebUI.verifyElementPresent(findTestObject('Page_Home\/lbl_WelcomeMessage'), 10, FailureHandling.CONTINUE_ON_FAILURE)) {\n    println('Element is present. Continuing loop.')\n}\nprintln('Element is not present. Loop exited.')\n<\/code><\/pre>\n\n\n\n<p>This code will verify if the element is present or not, and because we set the Failure Handling to \u201cContinue on Failure\u201d, it will always continue until it returns \u201cfalse\u201d (element not found) and exit the loop. The looping will also work using Failure Handling \u201cOptional\u201d as well:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>while (WebUI.verifyElementPresent(findTestObject('Page_Home\/lbl_WelcomeMessage'), 10, FailureHandling.OPTIONAL)) {\n    println('Element is present. Continuing loop.')\n    \/\/ Add your loop logic here\n}\nprintln('Element is not present. Loop exited.')\n<\/code><\/pre>\n\n\n\n<p>The loop will continue as long as the element is present. If the element is not found, the failure is logged but does not affect the test case outcome, and the loop stops.<\/p>\n\n\n\n<p>&#8220;Using &#8216;Stop on Failure&#8217; is not recommended in loops, as it will halt the entire test execution upon encountering a failure, preventing the loop from completing and stopping any subsequent code from running.\u201d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In katalon Studio, to have more control over our Test Case, we are able to mark our Test Case as \u201cPassed\u201d or \u201cFailed\u201d. Another option, there\u2019s a method in Katalon Studio called Failure Handling. As the name implies, it is used to tell Katalon Studio how to handle a failure, meaning if our test step [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,7],"tags":[],"class_list":["post-72","post","type-post","status-publish","format-standard","hentry","category-en","category-katalon-auto"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=\/wp\/v2\/posts\/72","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=72"}],"version-history":[{"count":2,"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=\/wp\/v2\/posts\/72\/revisions"}],"predecessor-version":[{"id":77,"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=\/wp\/v2\/posts\/72\/revisions\/77"}],"wp:attachment":[{"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=72"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=72"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kerjarapi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=72"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}