Skip to main content

Mark test's status for a Custom Keyword in Katalon Studio

  • You have a Katalon Studio Enterprise license.

Unlike built-in keywords, there will be no overall status for a Custom Keyword unless you define what your expected result is within the Custom Keyword. To generate a status for this one, Katalon Studio provides a couple of functions:

import org.openqa.selenium.By
import org.openqa.selenium.WebElement
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.util.KeywordUtil
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords

* Check if element present in timeout
* @param to Katalon test object
* @param timeout time to wait for element to show up
* @return true if element present, otherwise false
def isElementPresent(TestObject to, int timeout){
//Use Katalon built-in function to find elements with time out 1 seconds
List<WebElement> elements = WebUiBuiltInKeywords.findWebElements(to, timeout)
if (elements.size() > 0)
//Mark Passed status after this step
KeywordUtil.markPassed("Element is present")
//Mark Failed status after this step
KeywordUtil.markFailed("Element is not present")