In a testcase, when calling a custom keyword, how to pass parameters to the custom keyword?

Hello, i have a custom keyword as shown below:

class start_app {

  • Launch application and verify page load successfully
    def launchApp() {

    def var_forbidden = findTestObject(‘scr_assertionConsumer/h1_Forbidden’)
    def var_serviceTempUnavailable = findTestObject(‘scr_assertionConsumer/h1_Service Temporarily Unavailable’)

    try {
    if (WebUI.waitForElementVisible(var_forbidden, 1, FailureHandling.OPTIONAL) || WebUI.waitForElementVisible(var_serviceTempUnavailable, 1, FailureHandling.OPTIONAL)) {
    throw new StepErrorException(‘Access Forbidden!’)
    catch (StepErrorException e) {
    KeywordUtil.markFailedAndStop(‘Error message is shown, because you have not configure your IPs !!’)

In some testcases, the GlobalVariable.var_launchApp need to change to GlobalVariable.var_launchAppWSFed_0.

How can i used the same custom keyword and only change the parameter when creating the testcases where it will used the second variable?

The name of the variable shouldn’t matter if you make the keyword method more generic:

def launchApp(String app) {
try {


And in my testcase, how will i set it?

I don’t know. How are you selecting which global to use right now?

if(some_condition) {
} else {

Thank you this solution works for me :slight_smile: appreciated :slight_smile:

1 Like