Want to use a customkeyword in a customkeyword

As in the title I just want to use a customkeyword in another customkeyword.

CustomKeywords.'combobox_optionlist_select.Example

katalon finds the keyword first, but the it underlines it and says that it is invalid.

I am not sure what exactly your problem is. You have two custom keywords and you want to call second one within first one’s definition?
By the way, your CustomKeyword snippet looks invalid. It should be something like CustomKeywords.'combobox_optionlist_select.Example'()

exactly, i am opening a combobox in vaadin and want to select the items with a second keyword which is:

CustomKeywords.‘select._combobox_optionlist_select.Example’(row);

And is it not possible to call a ‘open-combobox’ keyword first and as a next step call second one which selects an item?

You can call keyword#2 in keyword#1’s definition as well.
But you have to create a new instance of keyword#2 unless the keyword is static.

thank you it seems that I got a mistake within the customkeyword

Mhm it worked some times, the other day, but now i have the error again:

groovy.lang.MissingMethodException: No signature of method: static CustomKeywords.ntt.Click.execute() is applicable for argument types: (com.kms.katalon.core.testobject.TestObject)

You are calling your method with invalid parameter (you provided TestObject, but no such a method exists). Some other parameter is expected.

If I understood correctly the invalid parameter is the customkeyword, which should not be, as I defined it correctly and it works if I use 2 items instead of refering in one customkeyword to the other customkeyword. But for the test suit I need to use the second way

I am afraid I don’t understand. This error is related to invalid method call. The same as if you have a method:

public static int sq(int num) {
    return num*num
}

and you call it this way:

sq("random string")

Your keyword CustomKeywords.ntt.Click.execute() is not able to take TestObject as a parameter, so you may need to find out how to pass a correct input there.

Ah sorry, I am using this code:

public class ClickSpan {
@Keyword
def execute(String caption) {

	def button = new TestObject("Button" + caption);
	button.addProperty("xpath", ConditionType.EQUALS, "(//span[@class='v-button-caption'][contains(text(),'" + caption + "')])[1]")
	WebUI.waitForElementPresent(button, 30);
	CustomKeywords.'ntt.Click.execute'(button)	
}

}

public class Click {

@Keyword
def execute() {
	WebUI.click(button);
}

}

Is there any of the mistakes you mentioned?

Because I cant find anything

Thank you!

There is. You call CustomKeywords.‘ntt.Click.execute’(button) but method is defined as execute().
Try this:

public class Click {
@Keyword
def execute(TestObject button) {
    WebUI.click(button);
    }
}

Thank you so much Marek, it works!

Is it possible to call a custom keyword from a second keyword that exists in a separate keyword package? I have not been able to implement this.

I want to be able to create methods in separate classes, but still be able to use those methods by other keywords IN SEPARATE PACKAGES AND CLASSES. It seems totally against the spirit of this tool to disable the call to CustomKeywords.‘package.class.method’() when you’re calling from a separate keyword class and package.

I am postitive that there’s a way to import other classes from separate keyword files, but none of the common sense syntax I’ve tried has gotten me anywhere. I need to access them from other packages.

Example:

I’m in package auth in class LoginMethods. I want to access package utility and class ‘getData’.

It seems like the syntax I need is something like:

import auth.LoginMethods

First one to respond gets a free tootsie roll, I’ll have it waiting for you at your doctor’s office next time you go to visit…

Aaaaaand, I got it.

Right track just have to declare a new instance of the class with the method your trying to invoke.

pseudo code:

import package.class

def x = new class().method()

x holds returned value from method()

'Why Customkeyword is underlined?'public class kw1 {
@Keyword
def execute1 (){
CustomKeywords.'my001.kw2.execute2'(0)
}
}
public class kw2 {
@Keyword
def execute2 (int input2){
input2 = 222
}
}

tod2020@mail.ru said:

'Why Customkeyword is underlined?'public class kw1 {

@Keyword
def execute1 (){
CustomKeywords.‘my001.kw2.execute2’(0)
}
}
public class kw2 {
@Keyword
def execute2 (int input2){
input2 = 222
}
}


  

I have the same issue.

I think that at this scope (in a custom keyword) Katalon can’t import CustomKeywords from (default package), or maybe missing some important configuration.

Any body has the same issue?

The idea es call one keword method from another keyword method in differents packages using CustomKeywords.‘xxxx’() sintax

Thanks for all.

1 Like