I am struggling here to generate an email ID that consists of Random First name and Random Last name. I don't want to use the dynamic Variable $randomEmail because it generates any random email which is totally different from the First name and Last name and looks very unrealistic.
I have a Pre-Requisite Script in Postman, Where I have two environment variables first_name and last_name, I use the faker library to generate dummy data as Following. The dynamic variable $randomFirstName and $randomLastName, generate and set the Environment variables as following. Let assume that $randomFirstName=John and $randomLastName=Doe
postman.setEnvironmentVariable("first_name", pm.variables.replaceIn('{{$randomFirstName}}'));
postman.setEnvironmentVariable("last_name", pm.variables.replaceIn('{{$randomFirstName}}'));
Now I want to use the Environment variable first_name and last_name to use in the following variable email_formatted to generate the email ID which is consisting of first name and last name.
email_formatted = "{{first_name}}" + '_' + "{{last_name}}" + '@gmail.com';
postman.setEnvironmentVariable("email", email_formatted);
console.log("Email: " + postman.getEnvironmentVariable("email"));
However, on the Consol, I am getting the following result.
ACTUAL "Email: {{first_name}}_{{last_name}}@gmail.com"
EXPECTED "Email: John_Doe@gmail.com"
I think I am doing some small mistakes here in syntax or how the Environment variables are used in the Pre-Requisite Script. Thanks for your time in reading, and any leads would be helpful