Introduction to custom keywords in Katalon Studio
Important:
- You have a Katalon Studio Enterprise license.
In addition to built-in keywords, you can define custom keywords to extend the capabilities of Katalon Studio. Once created, custom keywords can be used when executing test cases like other built-in keywords.
Create a keyword package
A package is a namespace that organizes a set of related classes and interfaces.
You can keep things organized by grouping related classes and interfaces into packages.
To create a keyword package, do as follows:
In the Tests Explorer section, a new package is created accordingly.
Create a custom keyword
Use custom keywords in the manual view
Use custom keywords in the script view
Work with custom keywords
The following classes and methods can be useful when working with custom keywords.
Class | Method | Description |
---|---|---|
DriverFactory | getWebDriver() | Get the currently active web driver. |
Test Object | addProperty(String name, ConditionType condition, String value) | Add a new property to the test object. |
setProperties(List<TestObjectProperty> properties) | Set the properties of the test object. | |
getObjectId() | Get object ID. | |
findPropertyValue(String name, boolean caseSensitive) | Find the value of a property using the property name. | |
Keyword Util | logInfo(String message) | Log the message as info. |
markError(String message) | Mark a keyword to be an error. | |
markErrorAndStop(String message) | Mark a keyword to be an error and stop execution. | |
markFailed(String message) | Mark a keyword to be failed and continue execution. | |
markFailedAndStop(String message) | Mark a keyword to be failed and stop execution. | |
markPassed(String message) | Mark a keyword to be passed. | |
markWarning(String message) | Mark a keyword to be a warning. |