I am doing a browser testing. I recorded recording1.rxrec. I recored it to go to http://www.cnn.com and then it verifys if it really goes to cnn.com. In 'Key Sequence' I have http://www.cnn.com.
Then I have some gibberish string in Key Sequence (i.e. EIERUIEIFJIEIRE #*$&^#) and it verifys if browser is saying no address found.
Now instead of using one Key Sequence, I would like to use a randomURLgenerator and randomSTRINGgenerator. I have found the following two functions but when I add them in Recording1.cs and close the program, I lose everything.
This code is for randomURLgenerator (uses one of the 10 URLs):
Code: Select all
public static string RandomString_URL_Array () //Generate random value from the array validURL
{
// Create array with valid URL links
string [] validURL = {"www.google.com", "www.yahoo.com", "www.ebay.com", "www.wikipedia.org", "www.att.com", "www.dice.com", "seleniumhq.org", "www.microsoft.com", "www.hulu.com", "www.java.com", "www.facebook.com"};
Random RandString = new Random();
string result = validURL[RandString.Next(0, validURL.Length)];
return result;
}
This is the code for randomSTRINGgenerator:
Code: Select all
public static string randomString (int numChars )
{
string[] chars = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "P", "Q", "R", "S",
"T", "U", "V", "W", "X", "Y", "Z","0","1", "2", "3", "4", "5", "6", "7", "8", "9" };
Random rnd = new Random();
string random = string.Empty;
for (int i = 0; i < numChars; i++)
{
random += chars[rnd.Next(0, chars.Length)];
}
return random;