The following is a simple solution that can be folded into your test scripts. It builds on the work of many others and has been confirmed to be working as desired. I tested it using a javascript framework:
Javascript customize to your heart’s content
var firstName = Math.random().toString(36).replace(/[^a-z]+/g, ‘’).substr(2, 3);
var lastName = Math.random().toString(36).replace(/[^a-z]+/g, ‘’).substr(2, 5);
var phoneLine = Math.random().toString().replace(‘0.’, ‘’).substr(0, 3);
var phoneExt = Math.random().toString().replace(‘0.’, ‘’).substr(0, 4);
var phoneNumber = ‘212’+phoneLine+phoneExt;
var auth_USN = ‘user_’+Math.random().toString().replace(‘0.’, ‘’).substr(0, 3);
var auth_PASS = ‘pAss’+Math.random().toString(36).replace(/[^a-z]+/g, ‘’).substr(0, 7)+‘!@#’;
var auth_EMAIL = ‘tester’+Math.random().toString().replace(‘0.’, ‘’).substr(0, 4)+‘@domain.com’;
JAVA
- Using Apache’s RandomStringGenerator class swap out Math.random() … with the class, where applicable
For Python - sub where necessary with the following:
- ‘’.join(random.choices(string.ascii_uppercase + string.digits, k=N))
source: Stack Overflow: Random string generation with upper case letters and digits in Python