How to use custom keyword inside a custom keyword


Is it possible to put a custom keyword inside a custom keyword in a test case?

Here are my custom keywords:

  1. CustomKeywords.‘myPackage.PDFVerification.isFileDownloaded’(String downloadPath, String fileName)
    • this verifies if the downloaded filename format is correct
  2. CustomKeywords.‘’()
    • this only prints the current date/time

I want custom keyword # 2 to be the ‘fileName’ in custom keyword #1.
I tried doing it so but it returns “null”.

Here’s what I did:

CustomKeywords.‘myPackage.PDFVerification.isFileDownloaded’(‘C:\Users\Admin\Downloads’, “Report”+CustomKeywords.‘’()+".csv")

Here’s the error message:

06-30-2019 10:29:41 PM Test Cases/Download PDF and Export Functions/RMS_Locate_AssetStatus_Export

Elapsed time: 21.478s



Test Cases/Download PDF and Export Functions/RMS_Locate_AssetStatus_Export FAILED.
com.kms.katalon.core.exception.StepFailedException: Report_null.csv does not exist in C:\Users\Admin\Downloads
at com.kms.katalon.core.util.KeywordUtil.markFailed(
at com.kms.katalon.core.util.KeywordUtil$ Source)
at myPackage.PDFVerification.isFileDownloaded(PDFVerification.groovy:41)
at myPackage.PDFVerification.invokeMethod(PDFVerification.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(
at com.kms.katalon.core.main.TestCaseExecutor.runScript(
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(
at com.kms.katalon.core.main.TestCaseExecutor.execute(
at com.kms.katalon.core.main.TestCaseMain.runTestCase(
at com.kms.katalon.core.main.TestCaseMain$runTestCase$ Source)

Thanks in advance.

String fname = CustomKeywords.‘’()
CustomKeywords.‘myPackage.PDFVerification.isFileDownloaded’("path", fname)

That will do what you asked, if I understood you correctly.

1 Like

I already tried that and still getting null. I am not sure why it is returning null because I can see in my console log that custom keyword for current date/time is being logged correctly (when I run it separately).

Oh wait, I put a semi-colon in my variable.

String fname = CustomKeywords.‘’();

I’ll just try it without the semi-colon.

This isn’t working. I tried to print the string and it also prints null. How do I get the log in the console? Because the correct date/time is logged there when I run the custom keyword for it.

String currentdatetime = CustomKeywords.‘’()
println "Current Date / Time: "+currentdatetime

But you haven’t shown me (us) “this”. Paste a copy of the CustomKeywords.‘’() method here.

package myPackage

import java.text.SimpleDateFormat

import com.kms.katalon.core.annotation.Keyword

public class DateTimeVerification {


def today() {

  Date date = new Date()
  String datePart = date.format("yyyyMMdd")
  String timePart = date.format("hhmm")

  println datePart+timePart


Sorry for that :smile:

And I’m sorry you deleted the post with info I was asking for. I was in the middle of replying to you when you deleted the post.

Sorry, but I don’t have time for this.

Good luck - you’re going to need a ton of it.

I’m very sorry :frowning: I thought I posted the wrong one. Thanks anyway :frowning:

Your keyword is just printing something, therefore returning null.
It should return a string with the value needed (datePart+timePart)

1 Like

@Ibus Thank you! It is working now :hugs: