Using additional custom methods in Custom Keywords

Hi!

I have an issue on how to use custom classes methods that I’ve written in Keyword methods when using tests.

Now the situation is as follows

I have 2 different packages, one for custom classes with keywords and one for helper classes and methods that I’d like to use withing said keywords.

For example, I have a class with keywords for handling login in my application:

def performLogin(){

WebUI.navigateToUrl(buildURL())

WebUI.setText(findTestObject(‘Login/input_user’), GlobalVariable.application_usr)

WebUI.setText(findTestObject(‘Login/input_passw’), GlobalVariable.application_passw)

WebUI.click(findTestObject(‘Login/btn_signIn’))

}

Since the application URL doesn’t work in the String format from the global variable (due to ports and such), I have to build the URL every time I want to use it. Since I don’t want to duplicate code, I also have a second package that builds the URL.

//Builds the URL from the global variable address

def buildURL(){

URI uri = new URI(“https”, null, GlobalVariable.application_url, 8080, null, null, null)

URL url = uri.toURL()

return url

}

However, no matter what I try to import or how I notate the call, I can’t see to get this working. When I run the test (and the execution goes Test → Keyword → buildURL), I always get the following error:

FAILED because (of) org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method

Can somebody help me with this?

def performLogin(){    WebUI.navigateToUrl(buildURL().toString())    ...

WebUI.navigateToUrl( … ) requires a String as argument. On the other hand, a call to buildURL() returns a URL object. Therefore you need to convert a URL object to a String object.

kazurayam said:

def performLogin(){    WebUI.navigateToUrl(buildURL().toString())    ...

WebUI.navigateToUrl( … ) requires a String as argument. On the other hand, a call to buildURL() returns a URL object. Therefore you need to convert a URL object to a String object.

That would eventually become an issue and I would fix it, but this is not the solution for the issue at hand. However this isn’t the solution to the issue which already occurs before the issue you mentioned.

None the less, I have manged to resolve the issue by myself, so this can be closed.