katalon-studio

Katalon : groovy.lang.MissingPropertyException : Using custom keyword in custom keyword


In Katalon, if I want to use CustomKeyword inside another CustomKeyword. I getting MissingPropertyException

Dialog Keywords

public class Dialog {

    @Keyword
    def clickCancel() {
      WebUI.click(findTestObject('Common/Components/Dialog/btn_Cancel'))
    }

    ...
}

Root Navigation Keywords

public class RootNavigations {

    @Keyword
    def checkDialogWorking() {
      WebUI.click(findTestObject('App/Page_Home/btn_OpenComparisons_Dialog_Home'))
      CustomKeywords.'com.app.Dialog.clickCancel'()
    }

    ...
}

Exception

Test Cases/Smoke Test/Application/Check Dialog 
FAILED because (of) (Stack trace: groovy.lang.MissingPropertyException: 
No such property: CustomKeywords for class: com.app.RootNavigations

Solution

  • import class into another Keyword class and declare its object to use that Keyword.

    Root Navigation Keywords

    public class RootNavigations {
    
        final dialog = new Dialog() // ******* imp step
    
        @Keyword
        def checkDialogWorking() {
          WebUI.click(findTestObject('App/Page_Home/btn_OpenComparisons_Dialog_Home'))
          this.dialog.clickCancel() // ******* imp step
        }
    
        ...
    }