Search Here!

Tuesday, April 24, 2012

Selenium: Generate Unique variable

This C# method helps to generate unique variable, you can use with element to maintain it's uniqueness.


public static string Generate_Unique_variable(string value)
        {
            string[] clCourse = new string[10];
            string fun_inter_org;
            clCourse[0] = inter_org;
            clCourse[1] = DateTime.Now.Year.ToString();
            clCourse[2] = DateTime.Now.Month.ToString();
            clCourse[3] = DateTime.Now.Day.ToString();
            clCourse[4] = DateTime.Now.Hour.ToString();
            clCourse[5] = DateTime.Now.Minute.ToString();
            clCourse[6] = DateTime.Now.Second.ToString();
            fun_inter_org = String.Concat(clCourse);
            return value;
        }
Generic.Generate_Unique_variable("myinputvalue");
It would input like 'myinputvalue42420121137'

No comments:

Post a Comment