How can I generate random domain name in using JMeter?
This is what I tried:
Random Variable
VariableName=domainName
OutputFormat=00000.com
MinumumValue=Aa
MaximumValue=Zz
SeedForRandomFunction=__RandomString
Though you have not mentioned which type of random domain names you want, I have considered some examples,
domain_00001.com
domain_03000.com
etc.
This can be created like,
In Beanshell preprocessor this code should yield the desired output, change it accordingly as per need.
import java.util.Random;
public class MyDomainRandomGen {
private static final String CHAR_LIST ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final int RANDOM_STRING_LENGTH = 10;
public String generateRandomDomain(){
StringBuffer randStr = new StringBuffer();
for(int i=0; i<RANDOM_STRING_LENGTH; i++){
int number = getRandomNumber();
char ch = CHAR_LIST.charAt(number);
randStr.append(ch);
}
String[] domains = {"de","com","in","en","us"};
int idx = new Random().nextInt(fruits.length);
String random = (fruits[idx]);
randStr.append(random)
return randStr.toString();
}
}