Exemple #1
0
        //Method for upload .bex enviroment into especific enviroment
        public static void EnvironmentAction(string indexPro, string indexEnv, string actionType)
        {
            try
            {
                Clog Clog = new Clog();

                Thread.Sleep(500); //wait set variables

                if (indexPro != "There aren't project")
                {
                    Thread.Sleep(5000);
                    //utils.WaitTimeForElement(PageObjectRun.ButtonCreateProject(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);
                    string idProject = Convert.ToString(indexPro);

                    if (indexEnv != "There aren't environment")
                    {
                        string idEnviroment = Convert.ToString(indexEnv);
                        string NewUrl;
                        switch (actionType)
                        {
                        case "loadbex":

                            utils.ClickTwoElements(PageObjectRun.ElementSelectProject(), PageObjectRun.ElementSelectEnviroment(), PageObjectRun.SelectMenuEnviroment(), Cconf.Instance.elemenType[1], idProject, idEnviroment);
                            AutoItX3 autoIt = new AutoItX3();
                            autoIt.WinActivate("File Upload");
                            autoIt.ControlGetFocus("File Upload");
                            Thread.Sleep(500);
                            autoIt.Send(Cconf.Instance.ListEnviromentsLoadBex[0, 1]);
                            Thread.Sleep(2000);     //wait write path .bex
                            autoIt.Send("{ENTER}");
                            Thread.Sleep(1000);     //come back run cloud
                            utils.Click(PageObjectRun.ButtonloadBex(), Cconf.Instance.elemenType[1]);
                            utils.WaitTimeForElement(PageObjectRun.LoadCreatedEnvironment(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);
                            string Waiting = utils.GetMessagesTwoVariables(PageObjectRun.ElementSelectProject(), PageObjectRun.ElementSelectEnviroment(), PageObjectRun.SelectStatusEnviroment(), Cconf.Instance.elemenType[1], null, idProject, idEnviroment);


                            while (Waiting == "Applying")
                            {
                                utils.writeLog("{0} upload package... \n", Waiting);
                                Waiting = utils.GetMessagesTwoVariables(PageObjectRun.ElementSelectProject(), PageObjectRun.ElementSelectEnviroment(), PageObjectRun.SelectStatusEnviroment(), Cconf.Instance.elemenType[1], null, idProject, idEnviroment);
                                Thread.Sleep(5000);    //wait to write log
                            }

                            if (Waiting == "Active")
                            {
                                utils.writeLog("The package has been upload successfully with state: {0} \n\n\n", Waiting);
                                utils.WaitTimeForElement(PageObjectRun.ButtonCloseAlert(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);
                                utils.Click(PageObjectRun.ButtonCloseAlert(), Cconf.Instance.elemenType[1]);
                                break;
                            }
                            else
                            {
                                utils.writeLog("\n----Can't upload package state: {0} ----\n\n", Waiting);
                                break;
                            }

                        case "delete":
                            utils.ClickTwoElements(PageObjectRun.ElementSelectProject(), PageObjectRun.ElementSelectEnviroment(), PageObjectRun.SelectTrashEnviroment(), Cconf.Instance.elemenType[1], idProject, idEnviroment);

                            utils.WaitTimeForElement(PageObjectRun.SetTextTrashEviroment(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);
                            utils.EnterText(PageObjectRun.SetTextTrashEviroment(), Cconf.Instance.ListEnviroments[0, 1], Cconf.Instance.elemenType[1]);
                            utils.ClickCheck(PageObjectRun.SetCheckTrashEnviroment(), Cconf.Instance.elemenType[1]);

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

                        case "run":
                            NewUrl = utils.GetMessagesTwoVariables(PageObjectRun.ElementSelectProject(), PageObjectRun.ElementSelectEnviroment(), PageObjectRun.GetUrlEnviroment(), Cconf.Instance.elemenType[1], "href", idProject, idEnviroment);
                            utils.ClickTwoElements(PageObjectRun.ElementSelectProject(), PageObjectRun.ElementSelectEnviroment(), PageObjectRun.ClickButtonRunEnviroment(), Cconf.Instance.elemenType[1], idProject, idEnviroment);
                            CopenBrowser.driver.SwitchTo().Window(CopenBrowser.driver.WindowHandles.Last());
                            utils.WaitTimeForElement(PageObjectEngine.LoginButton(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[0]);
                            utils.EnterText(PageObjectEngine.UserText(), Cconf.Instance.ListEnviromentsLoadBex[0, 2], Cconf.Instance.elemenType[0]);
                            utils.EnterText(PageObjectEngine.PasswordText(), Cconf.Instance.ListEnviromentsLoadBex[0, 3], Cconf.Instance.elemenType[0]);
                            utils.Click(PageObjectEngine.LoginButton(), Cconf.Instance.elemenType[0]);
                            utils.WaitTimeForElement(PageObjectEngine.bizagiLogo(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);
                            utils.assertElementImage(Cconf.Instance.scenaryLogoEngine, PageObjectEngine.bizagiLogo(), Cconf.Instance.elemenType[1], Cconf.Instance.copyLogoEngine);
                            CengineCloud.NewCase(CengineCloud.SearchCase(Cconf.Instance.ListEnviromentsLoadBex[0, 4]));
                            CengineCloud.LogoutEngine();
                            CopenBrowser.driver.Close();
                            CopenBrowser.driver.SwitchTo().Window(CopenBrowser.driver.WindowHandles.Last());
                            break;

                        case "reset":

                            utils.ClickTwoElements(PageObjectRun.ElementSelectProject(), PageObjectRun.ElementSelectEnviroment(), PageObjectRun.MenuEnvironment(), Cconf.Instance.elemenType[1], idProject, idEnviroment);
                            utils.Click(PageObjectRun.SelectResetEnvironment(), Cconf.Instance.elemenType[1]);
                            utils.WaitTimeForElement(PageObjectRun.textReset(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);
                            utils.ClickCheck(PageObjectRun.SetCheckTrashEnviroment(), Cconf.Instance.elemenType[1]);
                            utils.WaitTimeForElement(PageObjectRun.ButtonDelete(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);
                            utils.Click(PageObjectRun.ButtonDelete(), Cconf.Instance.elemenType[1]);
                            utils.WaitTimeForElement(PageObjectRun.LoadCreatedEnvironment(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);
                            string reseting = utils.GetMessagesTwoVariables(PageObjectRun.ElementSelectProject(), PageObjectRun.ElementSelectEnviroment(), PageObjectRun.StatusEnviroment(), Cconf.Instance.elemenType[1], null, idProject, idEnviroment);

                            Thread.Sleep(1000);
                            reseting = utils.GetMessagesTwoVariables(PageObjectRun.ElementSelectProject(), PageObjectRun.ElementSelectEnviroment(), PageObjectRun.StatusEnviroment(), Cconf.Instance.elemenType[1], null, idProject, idEnviroment);

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

                            if (reseting == "Active")
                            {
                                utils.writeLog("\nThe environment was reseted correctly", null);
                            }
                            else
                            {
                                utils.writeLog("\n----Can't reset environment state is {0}----\n\n", reseting);
                            }

                            NewUrl = utils.GetMessagesTwoVariables(PageObjectRun.ElementSelectProject(), PageObjectRun.ElementSelectEnviroment(), PageObjectRun.GetUrlEnviroment(), Cconf.Instance.elemenType[1], "href", idProject, idEnviroment);
                            utils.ClickTwoElements(PageObjectRun.ElementSelectProject(), PageObjectRun.ElementSelectEnviroment(), PageObjectRun.ClickButtonRunEnviroment(), Cconf.Instance.elemenType[1], idProject, idEnviroment);
                            CopenBrowser.driver.SwitchTo().Window(CopenBrowser.driver.WindowHandles.Last());
                            utils.WaitTimeForElement(PageObjectEngine.LoginButton(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[0]);
                            utils.EnterText(PageObjectEngine.UserText(), Cconf.Instance.ListEnviromentsLoadBex[0, 2], Cconf.Instance.elemenType[0]);
                            utils.EnterText(PageObjectEngine.PasswordText(), Cconf.Instance.ListEnviromentsLoadBex[0, 3], Cconf.Instance.elemenType[0]);
                            utils.Click(PageObjectEngine.LoginButton(), Cconf.Instance.elemenType[0]);
                            utils.WaitTimeForElement(PageObjectEngine.bizagiLogo(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);
                            utils.assertElementImage(Cconf.Instance.scenaryLogoEngine, PageObjectEngine.bizagiLogo(), Cconf.Instance.elemenType[1], Cconf.Instance.copyLogoEngine);
                            CengineCloud.NewCase(CengineCloud.SearchCase(Cconf.Instance.ListEnviromentsLoadBex[0, 4]));
                            CengineCloud.LogoutEngine();
                            CopenBrowser.driver.Close();
                            CopenBrowser.driver.SwitchTo().Window(CopenBrowser.driver.WindowHandles.Last());
                            break;

                        case "monitor":
                            utils.ClickTwoElements(PageObjectRun.ElementSelectProject(), PageObjectRun.ElementSelectEnviroment(), PageObjectRun.activityMonitor(), Cconf.Instance.elemenType[1], idProject, idEnviroment);
                            utils.WaitTimeForElement(PageObjectRun.buttonCloseMonitor(), Cconf.Instance.userTimeWait, Cconf.Instance.elemenType[1]);

                            utils.Click(PageObjectRun.buttonCloseMonitor(), Cconf.Instance.elemenType[1]);



                            break;

                        default:
                            utils.writeLog("\n----There aren't option to environment----", null);
                            break;
                        }
                    }
                    else
                    {
                        utils.writeLog("\n----Enviroment not found----", null);
                    }
                }
                else
                {
                    utils.writeLog("\n----Project not found----", null);
                }
            }
            catch (Exception ErrorM)
            {
                utils.writeLog("{0}", ErrorM.Message);
            }
        }