コード例 #1
0
 public static void writeLog(string Descr, string var)
 {
     try
     {
         Clog   Clog = new Clog();
         string temp = (var != null) ? string.Format(Descr, var) : Descr;
         Cconf.log = Clog.InitalizeLogFile();
         Cconf.log.WriteLine(temp);
         Console.WriteLine(temp);
         Cconf.log.Close();
     }
     catch (Exception ErrorM)
     {
         Clog Clog = new Clog();
         Cconf.log = Clog.InitalizeLogFile();
         Console.WriteLine(ErrorM.Message);
         Cconf.log.WriteLine(ErrorM.Message);
         Cconf.log.Close();
     }
 }
コード例 #2
0
        //Method for create enviroment in especific project
        public static void CreateEnviroments(string indexProject)
        {
            try
            {
                Thread.Sleep(500); //Set variable
                utils.assertElementText(Cconf.Instance.scenaryProjectName, Cconf.Instance.projectName, utils.GetMessagesTwoElements(PageObjectRun.ElementSelectProject(), PageObjectRun.CopyNameProject(), Cconf.Instance.elemenType[1], null, CrunCloud.SearchProject(Cconf.Instance.projectName)));

                if (indexProject != "There aren't project")
                {
                    string id = Convert.ToString(indexProject);
                    int    CountEnvToCreate = 0;
                    string EnvCreate        = Cconf.Instance.waitVar;
                    int    dimensionArray   = 0;

                    while (CountEnvToCreate < Cconf.Instance.ListEnviroments.GetLength(dimensionArray))
                    {
                        switch (Cconf.Instance.ListEnviroments[(CountEnvToCreate), 0].ToLower())
                        {
                        case "trial":
                            selectCategory = "1";
                            break;

                        case "basic b":
                            selectCategory = "2";
                            break;

                        case "standard s0":
                            selectCategory = "3";
                            break;

                        case "standard s1":
                            selectCategory = "4";
                            break;

                        case "standard s2":
                            selectCategory = "5";
                            break;

                        case "premium p1":
                            selectCategory = "5";
                            break;

                        case "premium p2":
                            selectCategory = "6";
                            break;

                        default:
                            selectCategory = "1";
                            break;
                        }

                        switch (Cconf.Instance.ListEnviroments[(CountEnvToCreate), 2].ToLower())
                        {
                        case "dev":
                            selectType = "1";
                            break;

                        case "test":
                            selectType = "2";
                            break;

                        case "stage":
                            selectType = "3";
                            break;

                        case "produccion":
                            selectType = "4";
                            break;

                        default:
                            selectType = "2";
                            break;
                        }

                        utils.ClickTwoElements(PageObjectRun.ElementSelectProject(), PageObjectRun.MenuProject(), Cconf.Instance.elemenType[1], id);

                        utils.WaitTimeForElementVar(PageObjectRun.ElementSelectProject(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1], id);
                        utils.ClickTwoElements(PageObjectRun.ElementSelectProject(), PageObjectRun.ItemCreateEnviroment(), Cconf.Instance.elemenType[1], id);

                        utils.WaitTimeForElementVar(PageObjectRun.SelectCategoryEnviroment(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1], selectCategory);
                        utils.ClickOneVariable(PageObjectRun.SelectCategoryEnviroment(), Cconf.Instance.elemenType[1], selectCategory);

                        utils.WaitTimeForElement(PageObjectRun.ButtonNextCategory(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);
                        utils.Click(PageObjectRun.ButtonNextCategory(), Cconf.Instance.elemenType[1]);

                        utils.WaitTimeForElement(PageObjectRun.EnviromentName(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);
                        utils.EnterText(PageObjectRun.EnviromentName(), Cconf.Instance.ListEnviroments[(CountEnvToCreate), 1], Cconf.Instance.elemenType[1]);

                        utils.WaitTimeForElementVar(PageObjectRun.EnviromentType(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1], selectType);
                        utils.ClickOneVariable(PageObjectRun.EnviromentType(), Cconf.Instance.elemenType[1], selectType);

                        utils.WaitTimeForElement(PageObjectRun.ButtonNextType(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);
                        utils.Click(PageObjectRun.ButtonNextType(), Cconf.Instance.elemenType[1]);


                        utils.WaitTimeForElement(PageObjectRun.ButtonCreateEnviroment(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);
                        utils.Click(PageObjectRun.ButtonCreateEnviroment(), Cconf.Instance.elemenType[1]);


                        utils.WaitTimeForElement(PageObjectRun.LoadCreatedEnvironment(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);
                        string Waiting = utils.GetMessagesTwoVariables(PageObjectRun.ElementSelectProject(), PageObjectRun.ElementSelectEnviroment(), PageObjectRun.StatusEnviroment(), Cconf.Instance.elemenType[1], null, id, EnvCreate);

                        Thread.Sleep(1000);

                        while (Waiting == "Creating")
                        {
                            utils.writeLog("{0} Environment... \n", Waiting);
                            Waiting = utils.GetMessagesTwoVariables(PageObjectRun.ElementSelectProject(), PageObjectRun.ElementSelectEnviroment(), PageObjectRun.StatusEnviroment(), Cconf.Instance.elemenType[1], null, id, EnvCreate);
                            Thread.Sleep(5000); // wait for validate environment status
                        }

                        if (Waiting == "Created")
                        {
                            Clog Clog = new Clog();
                            Cconf.log = Clog.InitalizeLogFile();
                            Cconf.log.WriteLine("\nThe environment " + Cconf.Instance.ListEnviroments[(CountEnvToCreate), 1] + " finished with state: " + Waiting + "\n\n");
                            Console.Write("\nThe environment " + Cconf.Instance.ListEnviroments[(CountEnvToCreate), 1] + " finished with state: " + Waiting + "\n\n");
                            Cconf.log.Close();
                        }
                        else
                        {
                            utils.writeLog("\n----Can't created environments end with state: {0} ----\n\n", Waiting);
                        }

                        CountEnvToCreate++;
                    }
                }

                else
                {
                    utils.writeLog("\n----There aren't project with this especific name: {0} ----", Cconf.Instance.projectName);
                }
            }
            catch (Exception ErrorM)
            {
                utils.writeLog("{0}", ErrorM.Message);
            }
        }