hi,sadly, im not familiar with coding, looking for registration auto test. How can i generate random variable for email field? (@ included)
You can create a custom keyword as follow
public class RandomEmail {
@Keyword
public String getEmail(String suffix,String prefix){
int randomNo = (int)(Math.random() * 1000);
return suffix + randomNo + "@" + prefix;
}
}
And then use in the test as follow
Rahul said:
You can create a custom keyword as follow
public class RandomEmail {
@Keyword
public String getEmail(String suffix,String prefix){
int randomNo = (int)(Math.random() * 1000);
return suffix + randomNo + "@" + prefix;
}
}
And then use in the test as follow ![](https://s3.amazonaws.com/katalon-forum/editor/cx/2eygakhjs9c0.png "Image: https://s3.amazonaws.com/katalon-forum/editor/cx/2eygakhjs9c0.png")
Tnx. Sadly im just started to learn coding. I created custom keyword, can i somehow input it in my registration test?
'Focus on email input'WebUI.focus(findTestObject('Page_Login/input_email_create'))'Generate random email using custom keyword'String Mail = CustomKeywords.'randomEmail.getEmail'('testing', 'testing.test')'Type random email generated in to email input'WebUI.sendKeys(findTestObject('Page_Login/input_email_create'), Mail)
Hi this not works for me, reason âmultiplecompilationerrorsexception: startup failedâ what is the reason?
hi @Rahul,
I have this error
Reason: groovy.lang.MissingPropertyException: No such property: CustomKeywords for class
can you help me?
@Then(âInvito un utenteâ)
def Invito_un_utente() {
Mobile.setText(findTestObject(âCarrier/28-invita utente/android.widget.EditText0 - Inserisci la ragione sociale dellaziendaâ),
âpittigghiuâ, 0)
String Mail = CustomKeywords.âcom.question.RandomEmail.getEmailâ(âtestingâ, âtesting.testâ)
WebUI.setText(findTestObject(âObject Repository/Carrier/28-invita utente/android.widget.EditText0 - Inserisci le-mail dellâ), Mail)
Mobile.tap(findTestObject(âCarrier/28-invita utente/android.widget.Button0 - CONFERMAâ), 0)
Mobile.tap(findTestObject(âCarrier/28-invita utente/android.widget.TextView0 - OKâ), 0)
Mobile.closeApplication()
}
custom k.
public class RandomEmail {
@Keyword
public String getEmail(String suffix,String prefix){
int randomNo = (int)(Math.random() * 1000);
return suffix + randomNo + â@â + prefix;
}