# BDD Testing: Step Definition files doesn't recognise Customkeywords

**URL:** <https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [October 9, 2018, 4:00pm UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639 "2018-10-09T16:00:17Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Natarajan\_Krishnamur](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@Natarajan\_Krishnamur](https://forum.katalon.com/u/Natarajan_Krishnamur)\
**Post date:** [October 9, 2018, 4:00pm UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/1 "2018-10-09T16:00:17Z")

</div>

Hi,  
I created a customkeyword and when trying to call it in my step def file, Katalon is unable to recognise it as a class.  
Whereas when I use it in my test case, Katalon can easily recognise it.  
Is Customkeyword currently being supported in step defs? if not, do you have any plans of incorporating it in the near future?  
Thanks  
Krish

---

<div class="post-metadata">

**Author:** ![Bogdan\_Alexandru](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/32.png) [@Bogdan\_Alexandru](https://forum.katalon.com/u/Bogdan_Alexandru)\
**Post date:** [October 11, 2018, 7:51am UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/2 "2018-10-11T07:51:09Z")

</div>

Hi,  
I also had this problem, but I managed to find kind of a work around. If you could provide the script of the Step Definition file, I could be able to help you.

---

<div class="post-metadata">

**Author:** ![Mateus\_Gomes\_Binatti](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Mateus\_Gomes\_Binatti](https://forum.katalon.com/u/Mateus_Gomes_Binatti)\
**Post date:** [October 11, 2018, 6:33pm UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/3 "2018-10-11T18:33:24Z")

</div>

Hello,

I am having this problem too.  
Not sure if we have to import some library or something like this, but in test case is easily recognized as Natajaran said.

Can anyone help us?

Best regards!

---

<div class="post-metadata">

**Author:** ![Brian\_Ducson](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brian_ducson/32/603_2.png) [@Brian\_Ducson](https://forum.katalon.com/u/Brian_Ducson)\
**Post date:** [October 12, 2018, 8:05am UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/4 "2018-10-12T08:05:52Z")

</div>

if you consider a custom keyword is a normal method in a class, could you call it in the script?

---

<div class="post-metadata">

**Author:** ![Natarajan\_Krishnamur](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@Natarajan\_Krishnamur](https://forum.katalon.com/u/Natarajan_Krishnamur)\
**Post date:** [October 25, 2018, 9:42am UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/5 "2018-10-25T09:42:23Z")

</div>

@Bogdan Alexandru @Brian Ducson @Mateus Gomes Binatti  
So this is what I have in my keywords section  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

class completeLogin {

/\*\*

\* Click element

\* @param to Katalon test object

\*/

@Keyword

def clickElement(TestObject to) {

try {

WebElement element = WebUiBuiltInKeywords.findWebElement(to);

KeywordUtil.logInfo(“Clicking element”)

element.click()

KeywordUtil.markPassed(“Element has been clicked”)

} catch (WebElementNotFoundException e) {

KeywordUtil.markFailed(“Element not found”)

} catch (Exception e) {

KeywordUtil.markFailed(“Fail to click on element”)

}

}

/\*\*

\* SendKeys element

\* @param to Katalon test objects

\*/

@Keyword

def enterText(TestObject to,String text){

try {

WebElement element = WebUiBuiltInKeywords.findWebElement(to);

KeywordUtil.logInfo(“Entering text”)

element.sendKeys(text)

KeywordUtil.markPassed(“Entered Text”)

} catch (WebElementNotFoundException e) {

KeywordUtil.markFailed(“unable to enter text”)

} catch (Exception e) {

KeywordUtil.markFailed(“Fail to enter text”)

}

}

}  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
When calling the above keyword using customkeywords inside my BDD step defs, it looks like this  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

CustomKeywords.‘mohcLoginPage.completeLogin.enterText’(findTestObject(‘MOHCLoginPage/usernameField’), ‘rcjclkxearbrumffp@email.com’)

CustomKeywords.‘mohcLoginPage.completeLogin.enterText’(findTestObject(‘MOHCLoginPage/passwordField’), ‘Tester12’)

CustomKeywords.‘mohcLoginPage.completeLogin.clickElement’(findTestObject(‘MOHCLoginPage/loginButton’))

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
And this is the stacktrace  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

Verification FAILED because (of) (Stack trace: com.kms.katalon.core.exception.StepFailedException: Keyword runFeatureFile was failed (Root cause: Feature file ‘Include/features/REG18.feature’ was failed)

at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:36)

at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy)

at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:56)

at com.kms.katalon.core.keyword.internal.KeywordMain$runKeyword.call(Unknown Source)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:141)

at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords.runFeatureFile(CucumberBuiltinKeywords.groovy:45)

at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$runFeatureFile$0.callStatic(Unknown Source)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:214)

at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords.runFeatureFile(CucumberBuiltinKeywords.groovy:95)

at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$runFeatureFile.call(Unknown Source)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)

at WSVerification1540460451991.run(WSVerification1540460451991:2)

at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:183)

at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:108)

at com.kms.katalon.core.main.WSVerificationExecutor.runScript(WSVerificationExecutor.java:145)

at com.kms.katalon.core.main.WSVerificationExecutor.doExecute(WSVerificationExecutor.java:139)

at com.kms.katalon.core.main.WSVerificationExecutor.processExecutionPhase(WSVerificationExecutor.java:122)

at com.kms.katalon.core.main.WSVerificationExecutor.accessMainPhase(WSVerificationExecutor.java:114)

at com.kms.katalon.core.main.WSVerificationExecutor.execute(WSVerificationExecutor.java:102)

at com.kms.katalon.core.main.TestCaseMain.runFeatureFile(TestCaseMain.java:129)

at com.kms.katalon.core.main.TestCaseMain$runFeatureFile$0.call(Unknown Source)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)

at TempTempCase1540460446834.run(TempTempCase1540460446834.groovy:21)

at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)

at groovy.lang.GroovyShell.run(GroovyShell.java:518)

at groovy.lang.GroovyShell.run(GroovyShell.java:507)

at groovy.ui.GroovyMain.processOnce(GroovyMain.java:653)

at groovy.ui.GroovyMain.run(GroovyMain.java:384)

at groovy.ui.GroovyMain.process(GroovyMain.java:370)

at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129)

at groovy.ui.GroovyMain.main(GroovyMain.java:109)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109)

at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)

)

---

<div class="post-metadata">

**Author:** ![Brian\_Ducson](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brian_ducson/32/603_2.png) [@Brian\_Ducson](https://forum.katalon.com/u/Brian_Ducson)\
**Post date:** [October 26, 2018, 2:55am UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/6 "2018-10-26T02:55:50Z")

</div>

The stack trace does not say where is wrong yet.

---

<div class="post-metadata">

**Author:** ![Natarajan\_Krishnamur](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@Natarajan\_Krishnamur](https://forum.katalon.com/u/Natarajan_Krishnamur)\
**Post date:** [October 30, 2018, 9:17am UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/7 "2018-10-30T09:17:06Z")

</div>

This is what it will say when it cant find the custom keyword property  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

groovy.lang.MissingPropertyException: No such property: CustomKeywords for class: xxxxxxxxxxxxxxxxxxxx

at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)

at org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:87)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)

at xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.groovy:84)

at ✽.I complete my online consultation(xxxxxxxxxxxxxxxxxxx.feature:8)

---

<div class="post-metadata">

**Author:** ![Brian\_Ducson](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brian_ducson/32/603_2.png) [@Brian\_Ducson](https://forum.katalon.com/u/Brian_Ducson)\
**Post date:** [October 30, 2018, 11:26am UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/8 "2018-10-30T11:26:53Z")

</div>

Natarajan,

CustomKeywords can be used in Test Case, Test Suite script. It is out of scope of Custom Keyword, and Step Definition (those place we have to create new classes).

In scope of CustomKeyword, or StepDefinition, you can use it as a normal function.  
- Create new instance of the class, and call the method  
- Declare the method as Static and use it.

Examples  
- Custom keyword:

```auto
class ParamTypes {
  @Keyword
  def map_variables(Map <String, String> my_map) {
    println my_map
  }
}

```

- Calling from Test case:

```auto
CustomKeywords.'com.common.types.ParamTypes.map_variables'([('last name') : 'ducson', ('first name') : 'brian'])

```

- Calling from another custom keyword (or in step definition class)

```auto
new ParamTypes().map_variables([('last name') : 'ducson', ('first name') : 'brian'])

```

---

<div class="post-metadata">

**Author:** ![Natarajan\_Krishnamur](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@Natarajan\_Krishnamur](https://forum.katalon.com/u/Natarajan_Krishnamur)\
**Post date:** [December 11, 2018, 3:59pm UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/9 "2018-12-11T15:59:24Z")

</div>

@Brian_Ducson thanks for your suggestion but it didnt work either. Can you show me a working example of using a keyword in step defs?

---

<div class="post-metadata">

**Author:** ![Brian\_Ducson](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brian_ducson/32/603_2.png) [@Brian\_Ducson](https://forum.katalon.com/u/Brian_Ducson)\
**Post date:** [December 11, 2018, 11:48pm UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/10 "2018-12-11T23:48:04Z")

</div>

They are working code that I copied from my sample. What is the error you got? Could you take screenshot on how you use it?

---

<div class="post-metadata">

**Author:** ![Ney\_Santana\_do\_Prado](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@Ney\_Santana\_do\_Prado](https://forum.katalon.com/u/Ney_Santana_do_Prado)\
**Post date:** [February 11, 2019, 8:50pm UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/11 "2019-02-11T20:50:33Z")

</div>

Hello Brian, @Brian_Ducson

Could you share a project with the example provided before?  
I am not able to call a external class on my groovy script.

---

<div class="post-metadata">

**Author:** ![Ney\_Santana\_do\_Prado](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@Ney\_Santana\_do\_Prado](https://forum.katalon.com/u/Ney_Santana_do_Prado)\
**Post date:** [February 11, 2019, 9:11pm UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/12 "2019-02-11T21:11:20Z")

</div>

@Brian_Ducson There was another issue on my project that was causing the issue.  
I am able to call methods.  
Thank you

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [February 11, 2019, 9:52pm UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/13 "2019-02-11T21:52:06Z")

</div>

> [@Brian\_Ducson](#):
>
> - Calling from another custom keyword (or in step definition class)
> 
> ```auto
> new ParamTypes().map_variables([('last name') : 'ducson', ('first name') : 'brian'])
> 
> ```

I think that in the Step Definition you need appropriate import statement:

```auto
import your.package.name.ParamTypes

```

---

<div class="post-metadata">

**Author:** ![Brian\_Ducson](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brian_ducson/32/603_2.png) [@Brian\_Ducson](https://forum.katalon.com/u/Brian_Ducson)\
**Post date:** [February 12, 2019, 8:27am UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/14 "2019-02-12T08:27:50Z")

</div>

Thank you ^^

---

<div class="post-metadata">

**Author:** ![Eric\_Montou](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/eric_montou/32/915_2.png) [@Eric\_Montou](https://forum.katalon.com/u/Eric_Montou)\
**Post date:** [November 7, 2019, 7:22pm UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/15 "2019-11-07T19:22:51Z")

</div>

Was there a solution found for this issue? It’s not very clear from reading the comments.

---

<div class="post-metadata">

**Author:** ![libra.soumya17](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/libra.soumya17/32/11959_2.png) [@libra.soumya17](https://forum.katalon.com/u/libra.soumya17)\
**Post date:** [February 27, 2020, 1:27pm UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/16 "2020-02-27T13:27:26Z")

</div>

I tried the same way but it did not work for me. Tried in step definition file as well as in another custom keyword as well.  
The custom keyword that im trying to call is from a plugin.  
Could you please suggest some solution?

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [February 27, 2020, 8:56pm UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/17 "2020-02-27T20:56:19Z")

</div>

Could you please make a new discussion for your issue, and provide information — your code, logs, screenshots. Please have a look at the following guidance.

> [@\[TIP\] How To Help Us Help You!](http://forum.katalon.com/t/tip-how-to-help-us-help-you/12919):
>
> My test is BROKEN! NOTHING WORKS! HELP ME! Relax. We get it. We really do. There are some pretty smart and clever people on this forum, but you must realize, they are not magicians or wizards or gods. They cannot see your code, they can’t see your errors and they don’t even know what your AUT is meant to do even though it might seem perfectly obvious to you. So please relax and follow the advice below, before you start writing your post. The advice below will tell you the exact information …

---

<div class="post-metadata">

**Author:** ![libra.soumya17](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/libra.soumya17/32/11959_2.png) [@libra.soumya17](https://forum.katalon.com/u/libra.soumya17)\
**Post date:** [February 28, 2020, 5:03am UTC](https://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/18 "2020-02-28T05:03:15Z")

</div>

> [@BDD Testing: Step definition files is not able to recognize the custom keywords from plugin](http://forum.katalon.com/t/bdd-testing-step-definition-files-is-not-able-to-recognize-the-custom-keywords-from-plugin/40449):
>
> Hi, I have one plugin for custom keywords which I’am trying to use in Step definition file. I have tried following ways: Using like normal custom keyword in groovy file : CustomKeywords.‘keywords.Package.method()’ Importing the package and using the function by creating class of the package as mentioned here ‘[BDD Testing: Step Definition files doesn't recognise Customkeywords - #5 by Natarajan\_Krishnamur](http://forum.katalon.com/t/bdd-testing-step-definition-files-doesnt-recognise-customkeywords/13639/5)’: import keywords.Package and in step def using like this: new Package().meth…

Please refer to this.
