Personally, there are all sorts of pseudo strings that you can find on various testing sites that don’t make any sense that you can “hardcode”, rather than run the random string maker routine, like below (I added the special characters as extra to see what happens for them as well):
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquam #866&!% sapien a risus dapibus.
However, if you want to see the random string maker in action, perhaps create a Keyword with a parameter of the length of String you want and then return the built up String, like:
@Keyword
public String randomStringMaker(int strLength) {
String s1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
Random rand = new Random()
StringBuilder sb = new StringBuilder()
for (int j = 1; j <= strLength; j++)
{
sb.append(s1.charAt(rand.nextInt(s1.length())))
}
return sb
}
I am not overly hyped on calling the Random function repeatedly instead of only once in your program, so maybe you can pass that in as well. I will let you do that.
Anyways, in your TC you would (you will have to replace “com” and “name” with your KeyWords location):
String str = CustomKeywords.'com.name.randomStringMaker'(7)
WebUI.setText(findTestObject('your test object'), str)