Unable to use Custom keywords in a method

Good Day,

I have a method that system will generate random name to username field but the CustomKeyword is not recognized

Any solution to call the Custom Keyword to other method?

Note that the CustomKeyword that I used I got it from
import com.thedeanda.lorem.Lorem
import com.thedeanda.lorem.LoremIpsum

It’s working under testcase level but within the groovy Custom Keyword is unable to identified

TC Level:


look here - callig kewords one from another was discussed here:

1 Like

Hi Andrej,

Sorry I can’t understand the solution that you are given to me
and I’m only new in the automation. I’m not sure how can I call Keywords to another class

my guess is, that 2nd image you posted is from your keyword where you are trying to call function defined in another keyword
so in 2nd case use

(new randomData.TestGenerator()).getRandomFirstName()

in case it will not work, please share relevant sources with us.

1 Like

Man!! Thank you so much!!! It is now working :smiley:

	@When("User enter valid username and password")
	def enterValidCredentials() {
		WebUI.setText(findTestObject('loginPage/txtUsername'),(new randomData.TestDataGenerator()).getRandomFirstName())
		WebUI.setText(findTestObject('loginPage/txtPassword'), GlobalVariable.password)
1 Like