I have a test case that has these verification steps that repeat in multiple areas. I know I can create them another test case and call them but is there a better way to do that by creating the steps and calling them within the test case? TIA!
Yes, there is a way to do that.
First, introduce yourself to Custom Keywords: https://docs.katalon.com/display/KD/Define+custom+keywords
Once you have a custom keyword working, you’ve learned how to create a method that belongs to a class. You’ve actually created your own Groovy (java) class where you can place more of your own method(s).
So, in brief…
package com.yourcompany
class YourClass {
@Keyword
def yourNewKeyword() {
WebUI.comment("This is my new keyword...")
}
...
Now you can create another method that contains the steps you want to repeat…
static void yourMethod() {
WebUI.comment("This is my new method...")
}
} // End YourClass
You can call your methods in any test case (use Script view), something like…
import static com.yourcompany.yourclass.*
WebUI.comment("Calling yourMethod...")
YourClass.yourMethod()
WebUI.comment("yourMethod completed.")
That’s a brief get-you-started intro - hope it helps.
Russ
2 Likes