How can I map custom keyword to buitin keyword

I create a new custom keyword SetText, how can I map this custom keyword SetText to builtin keyword SetText?
If we have no mapping, we have to manually modify builtin keyword to custom keyword when we have a new record.

@kazurayam

I suppose meta programming in Groovy can help with this ?

What do you mean “map this custom keyword to the builtin keyword”?

Do you want to completely replace the implementation of WebUI.setText(TestObject) with the one you created?

Why do you want to do it? You can call your one by one line: CustomKeywords.'your.package.YourClass.setText'(TestObject). Why isn’t it enough?

Anyway, the following Katalon Studio project of mine may give you some hint:

Especially the pandemic() method of


shows an example of applying Groovy metaprogramming technique to modify the behavior of Katalon Studio’s built-in keywords.

I need to always manually modify builtin keyword to my custom keywords when I use katalon to record a new testcase, which katalon will use the default builtin keyword . If I do that,it will be waste of time.

Thanks for you reply, it’s very helpful for me :grin:

thanks, maybe it will be helpul for me

How can I map a custom keyword (e.g., clickkeywordJS.groovy) to a built-in keyword (e.g., click)

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.

Thanks!

The above statements give you some info on mapping keywords. However, since you are working recording in the Manual mode, you probably should not be “mapping” your new keyword method to some other default method, yet. Read kazurayam’s response on “mapping” on your other question on this topic.
Edit: you can easily use “Search and Replace” after the fact with CRTL + F.

Start by reading the below link to create your custom keyword (don’t forget to put the phrase @Keyword above your method). Once you have created your custom keyword(s), you will be able to select it/them from your list you make. The below link tells you how.

Introduction to custom keywords in Katalon Studio | Katalon Docs

Sample:

	@Keyword
	def clickKeywordJS() {
         ...
	}

Edit: when you start to create a new keyword, KS allows you to create several “default” methods. If you accept the “default” methods, you can see what I mean how to create keywords properly, by example.

@mch

Have you already created a lot of Test Case scripts using Web Recorder that call WebUI.click() and/or WebUI.enhancedClick() ?

If so, you have a good reason why you require the “mapping”. You would want to avoid rewriting the scripts if possible. With the “Expando meta class” technique, possibly you can reduce the volume of code rewrite job.

Hi @grylion54,

I mean how to replace a custom keyword which I created to run the click button. My default button (Click - build-in) did not work.

And now I want to override the custom keyword with our default click in every test case. Please note that I prefer to use the ‘Record Mode’.

I have done it with a Test Listener (overclick) and a groovy function.

Thank you!