Hi team, can you please help me out in generating the random email for mobile automation or web automation.
There are many ways to generate a random string or email. I suggest you trying some provided solutions from this page: https://stackoverflow.com/questions/8138164/groovy-generate-random-string-from-given-character-set and select the appropriate solution to suitable from your current script.
Thanks for your feed back! Can you please help me out in case if i store random value in one variable and then use that variable in the script.
Thanks i have gotten the solution
if you have got the solution then please write the solution too. it may help someone and complete your queries too.
follow this link for randm data https://github.com/katalon-studio/CustomKeywords
you can use like:
WebUI.setText(findTestObject('Login Page of Demo Application/input_username'), CustomKeywords.'randomData.TestDataGenerator.getRandomFemaleName'()
you can also concat like this
WebUI.setText(findTestObject('Login Page of Demo Application/input_username'), CustomKeywords.'randomData.TestDataGenerator.getRandomFemaleName'()+'abcd')
package random
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.checkpoint.Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testcase.TestCase
import com.kms.katalon.core.testcase.TestCaseFactory
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.testdata.TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords
import internal.GlobalVariable
import MobileBuiltInKeywords as Mobile
import WSBuiltInKeywords as WS
import WebUiBuiltInKeywords as WebUI
public class Random_Profilefirstname {
@Keyword
def newcus(String var){
String alphabet = ((βAββ¦βNβ)+(βPββ¦βZβ)+(βaββ¦βkβ)+(βmββ¦βzβ)+(β2ββ¦β9β)).join()
def n = 6
def key
for(def i=0;i<50;i++){
key = new Random().with {
(1β¦n).collect { alphabet[ nextInt( alphabet.length() ) ] }.join()
}
}
Mobile.setText(findTestObject(βProfile update objects/android.widget.RelativeLayout3β),key, 0)
}
This is the code which i used to generate random string for first name last name. This will work for both mobile and web as well.