Adding unique users each test runs

Hi guys,
I’m sure this must have been answered one time or another… I have a two step goal i’m trying to achieve. Need some help with it.

  1. I want to add unique users for every test run:
    EX: Test run 1: Jane Doe
    Test run 2: Jane Doe+random string (preferably datestamp?)

  2. Now second part of it is ability to Search for this user + the random string.

Not looking for external data but doing it with code.

Why not use search?

image

Go ahead, click the image.

hello,

check this one lib

download faker from
https://jar-download.com/artifacts/com.github.javafaker/javafaker/0.16/source-code

excratc it to the project Drivers folder --> restart KS

import com.github.javafaker.Faker

List<String> names = new ArrayList<>();
Random rand = new Random();

for(int i = 0; i < 100; i++){
	Faker faker = new Faker(new Random(rand.nextInt(100000)));
	String name = faker.name().firstName();
	names.add(name);
	//System.out.println(name);
}
Set<String> namesSet = new HashSet<String>(names);

for(String s: namesSet){
	//System.out.println(s);
}
System.out.println("unique names in a list: "+namesSet.size());

unique names in a list: 100

@ashraf.madina Not sure if I am on target with the below, but I use this to create a new client for all my test runs. I allow the insert of a reference letter to give me more flexibility, but you can remove that if that suits your case. I break out when I know that I have a new reference (0 of 0 entries).

@Keyword
def createNewClient(String refLetter) {
int intMod = 0;
String strMod = ‘’;

	// allow a new client to be created for testing
	boolean isNewClient = false;
	while (isNewClient == false)
	{
		intMod = intMod + 1;
		strMod = (intMod < 10) ? '0' + Integer.toString(intMod) : Integer.toString(intMod);

		GlobalVariable.userName = "Jane Doe" + strMod + refLetter;
		// create new client for testing
		WebUI.click(findTestObject('Client Pages/input_clientSearch'))
		WebUI.setText(findTestObject('Client Pages/input_clientSearch'), GlobalVariable.userName )
		WebUI.click(findTestObject('Client Pages/button_Go'))
		WebUI.waitForPageLoad(10)
		if (WebUI.verifyTextPresent('Showing 0 to 0 of 0 entries', false)) {
			isNewClient = true;
		}
	}
}