Custom Keywords and Method call statements in Katalon Studio


This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/videos/custom_keywords_and_method_call_statements.html

I was trying to create custom keywords for Android Native application.

I have added mobile custom keyword under Keywords folder, ie I want add a sample custom keyword just perform tap action.

Snippet here :

class PlayerActions {

@Keyword

def tapOnPlayerLayer_Mobile(TestObject to, int timeout){

KeywordUtil.logInfo(“Tap on Player layer”+ to.getObjectId())

MobileElement mobileElement = MobileElementCommonHelper.findElement(to, timeout)

mobileElement.click()

}

}

Later I have called same from my test scrip

image.png

(4th Step)

in script mode :

CustomKeywords.‘PlayerActions.tapOnPlayerLayer_Mobile’(findTestObject(‘Android_POM/Layout_test’), 0)

While executing the test I get below error:

PlayerActions.tapOnPlayerLayer_Mobile(findTestObject(“Android_POM/Layout_test”), 0)

Elapsed time: 0.096s

Cannot invoke method click() on null object

But if we perform the same using

Mobile.tap(findTestObject(‘Android_POM/Layout’), 0)

test script executes properly.

Is there any bugs in Android Native app custom keywords ? I am able to perform custom keywords calls on Web application.

or is there any problem in custom keyword script ?