Getting No Signature method when passing array

I am trying to create a customkeyword and my argument types I am using are Object and arraylist. When I add that keyword in my test script I am getting following error

2020-01-28 14:32:40.180 ERROR k.k.c.m.CustomKeywordDelegatingMetaClass - :x: No signature of method: ciautils.ciaUtilities.verifyNavMenu() is applicable for argument types: (java.util.ArrayList, [Ljava.lang.String;)
values: [[[[CChromeDriver: chrome on WINDOWS (b38ca21408a7888723dada3d487892f8)] → css selector: .navigation-wrapper .navigation-menu .navigation-menu-item], …], …]
Possible solutions: verifyNavMenu(com.kms.katalon.core.testobject.TestObject, [Ljava.lang.String;)
2020-01-28 14:32:40.207 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Career_Landingpage FAILED.
Reason:
org.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No signature of method: ciautils.ciaUtilities.verifyNavMenu() is applicable for argument types: (java.util.ArrayList, [Ljava.lang.String;)
values: [[[[CChromeDriver: chrome on WINDOWS (b38ca21408a7888723dada3d487892f8)] → css selector: .navigation-wrapper .navigation-menu .navigation-menu-item], …], …]
Possible solutions: verifyNavMenu(com.kms.katalon.core.testobject.TestObject, [Ljava.lang.String;)

Here is my code

String careerNavbarList = [“test1”, “test2”, “test3”]
CustomKeywords.‘ciautils.ciaUtilities.verifyNavMenu’(menuListObj, careerNavbarList)

in customKeywords file

@Keyword
def verifyNavMenu(TestObject object, String menuname){
List menuItems = object
println("total menus "+menuItems.size())

}

hi,

List<String> careerNavbarList = new ArrayList<>()
careerNavbarList.add("test1")
careerNavbarList.add("test2")
careerNavbarList.add("test3")
CustomKeywords.‘ciautils.ciaUtilities.verifyNavMenu’(menuListObj, careerNavbarList)

@Keyword
def verifyNavMenu(TestObject object, List<String> menuname){
	println("total menus "+menuname.size())
	for(String s : menuname){
	   println("menuiten name: "+s)
	}

I don't understand this line at all
"List menuItems = object"
1 Like

I am still getting the error even after I updated as you mentioned. but this time its related to java.util.List. I even added import java.util.List

2020-01-28 15:19:04.467 ERROR k.k.c.m.CustomKeywordDelegatingMetaClass - :x: No signature of method: ciautils.ciaUtilities.verifyNavMenu() is applicable for argument types: (java.util.ArrayList, java.util.ArrayList) values: [[[[CChromeDriver: chrome on WINDOWS (0dbdf8347eabc22b6b727201ad0f49e6)] → css selector: .navigation-wrapper .navigation-menu .navigation-menu-item], …], …]
Possible solutions: verifyNavMenu(com.kms.katalon.core.testobject.TestObject, java.util.List)

regarding List menuItems = object the object has webelement that was passed in the method and getting the list of that object on runtime.

hi,

is your keyword created as it should be in Katalon Studio under Keywords folder?
package
groovy class
@Keyword
method

Yes, I even have another keywords in the same package and able to use that

package ciautils
public class ciaUtilities {
@Keyword
def verifyNavMenu(TestObject object, List menuname){
}
}

hi,
my script tested without object

List<String> careerNavbarList = new ArrayList<>()
careerNavbarList.add("test1")
careerNavbarList.add("test2")
careerNavbarList.add("test3")
//CustomKeywords.‘ciautils.ciaUtilities.verifyNavMenu’(menuListObj, careerNavbarList)
verifyNavMenu(careerNavbarList)

def verifyNavMenu(List<String> menuname){
	println("total menus "+menuname.size())
	for(String s : menuname){
	   println("menuiten name: "+s)
	}
}

total menus 3
menuiten name: test1
menuiten name: test2
menuiten name: test3

I think I am declaring the object in wrong way.

menuListObj = driver.findElements(By.cssSelector(“.navigation-wrapper .navigation-menu .navigation-menu-item”))
CustomKeywords.‘ciautils.ciaUtilities.verifyNavMenu’(menuListObj, careerNavbarList)

So should I declare the object as webelement?

1 Like

Even as you mentioned when I run without the object I am still getting the following error

groovy.lang.MissingMethodException: No signature of method: Script1580161905483.verifyNavMenu() is applicable for argument types: (java.util.ArrayList) values: [[test1, test2, test3]]
at Career_Landingpage.run(Career_Landingpage:42)

hi,

try to clean your project
Project --> Close and clean up

1 Like

I tried cleaning and also restarted the application. Still got the error. So I recreated new keyword package and tried. That time it worked with no issues. After that I retried the old package and that one also worked normally. Not sure what went wrong and what did got fixed. How ever thanks for the quick replies and the help.

Well, your call

menuListObj = driver.findElements(…)

doesn’t return a TestObject, but a List… if your passing that to “verifyNavMenu” as your first parameter while it expects a ‘TestObject’…

If you read one of your exceptions carefully it actually states so:

No signature of method: ciautils.ciaUtilities.verifyNavMenu() is applicable for argument types: (java.util.ArrayList, java.util.ArrayList)

It says: you are passing 2 parameters, both are lists, but that’s not allowed.