Skip to end of metadata
Go to start of metadata

Hypothetically, you want to call a Custom Keyword within a Custom Keyword that is defined in another class. Check out the code below for a sample implementation.




Keywords/my.a/Greeting.groovy

package my.a
import com.kms.katalon.core.annotation.Keyword
class Greeting {
 @Keyword
 def greet(String someone) {
 return my.b.AI.sayHelloTo(someone)
 }
}

Keywords/my.b/AI.groovy

package my.b
class AI {
 static def sayHelloTo(String someone) {
 return "Hello, ${someone}."
 }
}


TC1:

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
def str = CustomKeywords.'my.a.Greeting.greet'("Drunda")
WebUI.comment(">>> ${str}")


The TC1 ran fine:


Credit to kazurayam

  • No labels