I need to test a page for a free sample. However, each email address can only be used once.
How can I generate random email addresses to run this test? I saw another article related to this, but the links in the article were broken.
Thanks
Wade
12 Answers, 1 is accepted
You can create a list with preset emails and use our data driven testing feature.
Regards,
Ivaylo
Telerik
Since this is not working for you then you need to use your own coded solution with generating a random string and use it as your email address.
Regards,
Ivaylo
Telerik
Regarding the coded solution unfortunately we do not have such a samples to provide, however you can always take a look over the Internet and find a suitable solution. A good starting point can be this article:
http://stackoverflow.com/questions/730268/unique-random-string-generation
The other solution with using the databinding is also applicable if you create a list long enough for your needs.
Thank you for your understanding.
Regards,
Ivaylo
Telerik
I am glad to hear you have found a solution and thank you for sharing it in the public forum. This could be of a great help of other customers.
Thank you for your cooperation.
Regards,
Ivaylo
Telerik
Here are a couple of functions for generating random character and number strings that take the desired length of string. For the string one, you can add your own combination of upper/lower letters, numbers, etc to the charSet string.
Then in your coded step do something like this
Manager.Desktop.KeyBoard.TypeText(randomString(7) + "@" + randomString(4) + ".com", 50, 100, true)
or
Manager.Desktop.KeyBoard.TypeText(randomString(7) + "@emailprovider.com", 50, 100, true)
public string randomString(int l)
{
//Define the length of the text
int length = l;
//Define the included characters
string charSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
Random random = new System.Random();
string randomText = new String(Enumerable.Repeat(charSet, length).Select(set => set[random.Next(set.Length)]).ToArray());
return randomText;
}
public string randomNumber(int l)
{
System.Text.StringBuilder num = new System.Text.StringBuilder();
Random random = new System.Random();
for (int i=0; i<l-1; i++)
{
//pick digit [0-9]
int digit = random.Next(9);
num.Append(digit);
}
return num.ToString();
}
Thank you sharing your knowledge with the community.
@Denise, do you need further assistance on this?
Hope to hear from you soon.
Regards,
Boyan Boev
Telerik by Progress