This is a migrated thread and some comments may be shown as answers.

Here is the code I used to create randome email addresses

4 Answers 306 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Wade
Top achievements
Rank 1
Wade asked on 18 Mar 2015, 12:24 AM
This code will create a random email address.

There are two extracted values, myRandomEmail and ConfirmEmail. The first can be used if you just need a single email address, the second can be used if you have to enter the same email as a confirmation email, like and account setup page.

You just pop this puppy in a coded step.

StringBuilder sb = new StringBuilder();<br>Random rnd = new Random();<br>char ch;<br>for (int ctr = 0; ctr < 9; ctr++)
{
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * rnd.NextDouble() + 65)));
sb.Append(ch);
}
sb.Append(
"@GMAIL.COM");
this
.SetExtractedValue("myRandomEmail",sb.ToString());
this.SetExtractedValue("ConfirmEmail",sb.ToString());

4 Answers, 1 is accepted

Sort by
0
Wade
Top achievements
Rank 1
answered on 18 Mar 2015, 04:32 PM
StringBuilder sb = new StringBuilder();
Random rnd = new Random();
char ch;
for (int ctr = 0; ctr < 9; ctr++)
 
{
 
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * rnd.NextDouble() + 65)));
 
sb.Append(ch);
 
}
 
sb.Append("@GMAIL.COM");
 
this.SetExtractedValue("myRandomEmail",sb.ToString());
 
this.SetExtractedValue("ConfirmEmail",sb.ToString());
0
Accepted
Boyan Boev
Telerik team
answered on 20 Mar 2015, 12:50 PM
Hello Wade,

Thank you for sharing the code. 

We really appreciate it.

Regards,
Boyan Boev
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
George
Top achievements
Rank 1
answered on 06 Apr 2016, 11:28 AM

Hi Wade, thanks for your code, but how can I use this in my coded steps in the Test Studio, also how can I generate a random number to create random users etc. I followed example on Test Studio documentation that didn't work. pls can you help

0
Boyan Boev
Telerik team
answered on 11 Apr 2016, 07:30 AM
Hello George,

Here is how to create a coded step.

What does't not work in our example for creating a random number. Please give us more detailed information so we can give a solution.

Hope to hear from you soon.

Regards,
Boyan Boev
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Wade
Top achievements
Rank 1
Answers by
Wade
Top achievements
Rank 1
Boyan Boev
Telerik team
George
Top achievements
Rank 1
Share this question
or