示例#1
0
        public AutomationElement TypeInXenCenterSearchBox(AutomationElement XenCenterObj, string TextToType, int TerminateStatus, string LogFilePath)
        {
            Logger NewLogObj = new Logger();

            NewLogObj.WriteLogFile(LogFilePath, "TypeInXenCenterSearchBox", "info");
            NewLogObj.WriteLogFile(LogFilePath, "=============================", "info");

            try
            {
                AutomationElementIdentity GuiObj = new AutomationElementIdentity();
                PropertyCondition         WindowReturnCondition  = GuiObj.SetPropertyCondition("AutomationIdProperty", "TreeSearchBox", 1, LogFilePath);
                AutomationElement         SearchDialogObj        = GuiObj.FindAutomationElement(XenCenterObj, WindowReturnCondition, TreeScope.Descendants, "Search Box", 1, LogFilePath);
                PropertyCondition         TextBoxReturnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "textBox1", 1, LogFilePath);
                AutomationElement         SearchTextDialogObj    = GuiObj.FindAutomationElement(SearchDialogObj, TextBoxReturnCondition, TreeScope.Descendants, "Search Box", 1, LogFilePath);
                GuiObj.SetTextBoxText(SearchTextDialogObj, TextToType, "Search Box", 1, LogFilePath);
                string TextSet = GuiObj.GetTextBoxText(SearchTextDialogObj, "Search Box Text", 1, LogFilePath);
                //MbUnit.Framework.Assert.AreEqual(TextToType, TextSet);
                return(SearchDialogObj);
            }
            catch (Exception Ex)
            {
                NewLogObj.WriteLogFile(LogFilePath, "Exception at TypeInXenCenterSearchBox" + Ex.ToString(), "fail");
                if (TerminateStatus == 1)
                {
                    NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 1.", "info");

                    NewLogObj.WriteLogFile(LogFilePath, "***Exiting application from TypeInXenCenterSearchBox as main menunot found**", "fail");

                    FileOperations FileObj = new FileOperations();
                    FileObj.ExitTestEnvironment();
                    return(null);
                }
                else
                {
                    NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 0.", "info");
                    return(null);
                }
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            string XenCenterInstallStatusFile = "C:\\XenCenterInstalled.txt";

            String TestStatus = "Pass";
            Logger NewLogObj  = new Logger();

            NewLogObj.CreateLogFolder();
            string LogFilePath = NewLogObj.CreateLogFile();

            NewLogObj.WriteLogFile(LogFilePath, "Test : Installer", "info");
            NewLogObj.WriteLogFile(LogFilePath, "======================", "info");

            if (File.Exists(XenCenterInstallStatusFile))
            {
                File.Delete(XenCenterInstallStatusFile);
            }
            FileOperations FileObj       = new FileOperations();
            string         InputFilePath = FileObj.GetInputFilePath(LogFilePath, "Inputs.txt");

            string InstallerLocation          = FileObj.GetInputPattern(InputFilePath, "InstallerLocation");
            string InstallerProcessName       = FileObj.GetInputPattern(InputFilePath, "InstallerProcessName");
            string LocationToInstallXenCenter = FileObj.GetInputPattern(InputFilePath, "LocationToInstallXenCenter");
            string XenCenterVersion           = FileObj.GetInputPattern(InputFilePath, "XenCenterVersion");

            string SetUpWindowTitle   = "Citrix XenCenter Setup";
            string InterruptedDialog  = "Citrix XenCenter Setup Wizard was interrupted";
            string HelpMenu           = "&Help";
            string AboutXenCenterMenu = "&About XenCenter";

            string LocalizedFilePath = FileObj.GetLocalizedFilePath();

            //if (LocalizedFilePath != null)
            //{
            SetUpWindowTitle   = FileObj.GetLocalizedMappedPattern(LocalizedFilePath, SetUpWindowTitle);
            InterruptedDialog  = FileObj.GetLocalizedMappedPattern(LocalizedFilePath, InterruptedDialog);
            HelpMenu           = FileObj.GetLocalizedMappedPattern(LocalizedFilePath, HelpMenu);
            AboutXenCenterMenu = FileObj.GetLocalizedMappedPattern(LocalizedFilePath, AboutXenCenterMenu);
            //}
            //else
            //{
            //    //Substitue the &
            //    HelpMenu = FileObj.RemovePatternFromString(HelpMenu, "&");
            //    AboutXenCenterMenu = FileObj.RemovePatternFromString(AboutXenCenterMenu, "&");

            //}

            //string InputFilePath1 = FileObj.GetInputFilePath(LogFilePath, "Mapped_CH.txt");
            //string SetupWindowTitle = FileObj.SearchFileForPattern(InputFilePath1, "Citrix XenCenter Setup", 1, LogFilePath);
            //int IndexEqual2 = SetupWindowTitle.IndexOf("=");
            //SetupWindowTitle = SetupWindowTitle.Substring(IndexEqual2 + 1);
            Console.WriteLine("InstallerLocation " + InstallerLocation);
            Console.WriteLine("InstallerProcessName " + InstallerProcessName);

            Generic GenricObj = new Generic();

            GenricObj.StartProcess(InstallerLocation, InstallerProcessName, LogFilePath, 1);
            Thread.Sleep(5000);
            //Console.WriteLine("handling UAC");
            ////Assuming that UAC prompt is on the screen
            //System.Windows.Forms.SendKeys.SendWait("{LEFT}");
            //Thread.Sleep(1000);
            //System.Windows.Forms.SendKeys.SendWait("{ENTER}");
            //Thread.Sleep(3000);
            // Console.WriteLine("Click send to UAC");

            AutomationElementIdentity GuiObj = new AutomationElementIdentity();
            PropertyCondition         WindowReturnCondition = GuiObj.SetPropertyCondition("NameProperty", SetUpWindowTitle, 1, LogFilePath);
            AutomationElement         SetupDialogObj        = GuiObj.FindAutomationElement(AutomationElement.RootElement, WindowReturnCondition, TreeScope.Children, "Xencenter Setup window", 1, LogFilePath);

            Console.WriteLine("Checking for SetupDialog ");
            NewLogObj.WriteLogFile(LogFilePath, "Checking for SetupDialog", "info");

            int WaitTimeOut = 240000;//3 mins
            int timer       = 0;

            while (SetupDialogObj == null && timer < WaitTimeOut)
            {
                SetupDialogObj = GuiObj.FindAutomationElement(AutomationElement.RootElement, WindowReturnCondition, TreeScope.Children, "Xencenter Setup window", 1, LogFilePath);
                Thread.Sleep(3000);
                timer = timer + 3000;
                NewLogObj.WriteLogFile(LogFilePath, "Waiting for SetupDialog", "info");
                Console.WriteLine("Waiting for SetupDialog ");
            }
            if (SetupDialogObj == null && timer < WaitTimeOut)
            {
                Console.WriteLine("Timeout waiting for setup dialog obj.Exiting.. ");
                Console.WriteLine("Timeout waiting for SetupDialog obj.Exiting.. ");
                FileObj.ExitTestEnvironment();
            }
            NewLogObj.WriteLogFile(LogFilePath, "SetupDialog obj found", "info");
            Console.WriteLine("SetupDialog obj found ");
            //Click cancel btn & verify actions
            Program PgmObj = new Program();

            PgmObj.ClickCancel(SetupDialogObj, SetUpWindowTitle, "yes");
            PgmObj.CheckInterruptedDialog(WindowReturnCondition, InterruptedDialog);
            PgmObj.ClickFinishBtn(WindowReturnCondition);;

            //Start installer again
            GenricObj.StartProcess(InstallerLocation, InstallerProcessName, LogFilePath, 1);
            Thread.Sleep(3000);

            SetupDialogObj = GuiObj.FindAutomationElement(AutomationElement.RootElement, WindowReturnCondition, TreeScope.Children, "Xencenter Setup window", 1, LogFilePath);

            timer = 0;
            while (SetupDialogObj == null && timer < WaitTimeOut)
            {
                SetupDialogObj = GuiObj.FindAutomationElement(AutomationElement.RootElement, WindowReturnCondition, TreeScope.Children, "Xencenter Setup window", 1, LogFilePath);
                Thread.Sleep(3000);
                timer = timer + 3000;
                NewLogObj.WriteLogFile(LogFilePath, "Waiting for SetupDialog", "info");
                Console.WriteLine("Waiting for SetupDialog ");
            }
            if (SetupDialogObj == null && timer < WaitTimeOut)
            {
                Console.WriteLine("Timeout waiting for setup dialog obj.Exiting.. ");
                Console.WriteLine("Timeout waiting for SetupDialog obj.Exiting.. ");
                FileObj.ExitTestEnvironment();
            }

            //Click cancel & no
            PgmObj.ClickCancel(SetupDialogObj, SetUpWindowTitle, "no");
            //Verify SetupDialogObj is still there
            SetupDialogObj = GuiObj.FindAutomationElement(AutomationElement.RootElement, WindowReturnCondition, TreeScope.Children, "Xencenter Setup window", 1, LogFilePath);
            if (SetupDialogObj != null)
            {
                NewLogObj.WriteLogFile(LogFilePath, "SetupDialogObj is there after pressing on no btn", "info");
            }

            PropertyCondition NextBtnReturnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "613", 1, LogFilePath);
            AutomationElement NextBtnObj             = GuiObj.FindAutomationElement(SetupDialogObj, NextBtnReturnCondition, TreeScope.Descendants, "Next Btn", 1, LogFilePath);

            GuiObj.ClickButton(NextBtnObj, 1, "Next Button", 1, LogFilePath);

            SetupDialogObj = GuiObj.FindAutomationElement(AutomationElement.RootElement, WindowReturnCondition, TreeScope.Children, "Xencenter Setup window", 1, LogFilePath);
            ////Destination text
            //PropertyCondition DestinationTextReturnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "679", 1, LogFilePath);
            //AutomationElement DestinationTextObj = GuiObj.FindAutomationElement(SetupDialogObj, DestinationTextReturnCondition, TreeScope.Descendants, "Xencenter install DestinationTextObj", 1, LogFilePath);
            //Click on browse btn
            PropertyCondition BrowseBtnReturnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "683", 1, LogFilePath);
            AutomationElement BrowseBtnObj             = GuiObj.FindAutomationElement(SetupDialogObj, BrowseBtnReturnCondition, TreeScope.Descendants, "Next Btn", 1, LogFilePath);

            GuiObj.ClickButton(BrowseBtnObj, 1, "Browse Button", 1, LogFilePath);
            //Verify if child winodw with xencenter location has apperaed
            AutomationElement LocationChildWndObj = GuiObj.FindAutomationElement(SetupDialogObj, WindowReturnCondition, TreeScope.Descendants, "Xencenter install location browse", 1, LogFilePath);
            //LOcate the textbox having location
            PropertyCondition LocationEditCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "547", 1, LogFilePath);
            AutomationElement LocationObj           = GuiObj.FindAutomationElement(LocationChildWndObj, LocationEditCondition, TreeScope.Descendants, "Xencenter install location edit box", 1, LogFilePath);

            GuiObj.SetTextBoxText(LocationObj, LocationToInstallXenCenter, "Xencenter Install location textbox", 1, LogFilePath);

            PropertyCondition OKBtnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "549", 1, LogFilePath);
            AutomationElement OKbtnObj       = GuiObj.FindAutomationElement(LocationChildWndObj, OKBtnCondition, TreeScope.Descendants, "Xencenter install location edit box", 1, LogFilePath);

            GuiObj.ClickButton(OKbtnObj, 1, "OK Button", 1, LogFilePath);
            Thread.Sleep(2000);
            //find the radio btns
            PropertyCondition ForAllRadioBtnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "507", 1, LogFilePath);
            AutomationElement ForAllradioBtnObj       = GuiObj.FindAutomationElement(SetupDialogObj, ForAllRadioBtnCondition, TreeScope.Descendants, "Xencenter install for all radiobtn", 1, LogFilePath);

            GuiObj.SetRadioButton(ForAllradioBtnObj, "Install for all radioBytn", 1, LogFilePath);
            Thread.Sleep(1000);

            PropertyCondition ForMeRadioBtnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "781", 1, LogFilePath);
            AutomationElement ForMeradioBtnObj       = GuiObj.FindAutomationElement(SetupDialogObj, ForMeRadioBtnCondition, TreeScope.Descendants, "Xencenter install for all radiobtn", 1, LogFilePath);

            GuiObj.SetRadioButton(ForMeradioBtnObj, "Install for me radioBytn", 1, LogFilePath);
            Thread.Sleep(1000);

            //Click next btn
            PropertyCondition Next1BtnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "613", 1, LogFilePath);
            AutomationElement Next1BtnObj       = GuiObj.FindAutomationElement(SetupDialogObj, Next1BtnCondition, TreeScope.Descendants, "Xencenter install for all radiobtn", 1, LogFilePath);

            GuiObj.ClickButton(Next1BtnObj, 1, "Next Button", 1, LogFilePath);

            SetupDialogObj = GuiObj.FindAutomationElement(AutomationElement.RootElement, WindowReturnCondition, TreeScope.Children, "Xencenter Setup window", 1, LogFilePath);
            //Click install btn
            PropertyCondition InstallBtnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "648", 1, LogFilePath);
            AutomationElement InstallBtnObj       = GuiObj.FindAutomationElement(SetupDialogObj, InstallBtnCondition, TreeScope.Descendants, "Xencenter install for all radiobtn", 1, LogFilePath);

            GuiObj.ClickButton(InstallBtnObj, 1, "Install Button", 1, LogFilePath);
            AutomationElement FinishBtnObj = PgmObj.WaitTillFinishButtonIsActive(WindowReturnCondition);

            if (FinishBtnObj == null)
            {
                NewLogObj.WriteLogFile(LogFilePath, "Xencenter installation timeout", "fail");
                NewLogObj.WriteLogFile(LogFilePath, "Exiting ...", "fail");
                FileObj.ExitTestEnvironment();
            }

            GuiObj.ClickButton(FinishBtnObj, 0, "Finish Button", 1, LogFilePath);
            File.Create(XenCenterInstallStatusFile);
            PgmObj.CheckXenCenterInstalledVersion(HelpMenu, AboutXenCenterMenu, XenCenterVersion);

            FileObj.FinishCurrentTest("Installer");
        }
示例#3
0
        public void ConnectToXenserver(AutomationElement XenCenterObj, string ServerName, string LogFilePath, int TerminateStatus, string Password)
        {
            Logger NewLogObj = new Logger();

            NewLogObj.WriteLogFile(LogFilePath, "ConnectToXenserver", "info");
            NewLogObj.WriteLogFile(LogFilePath, "=================", "info");
            int ConnecToServerTimeOut        = 60000;
            AutomationElementIdentity GuiObj = new AutomationElementIdentity();

            try
            {
                AutomationElement XenCenterNodeFound = ClickOnXenCenterNode(XenCenterObj, LogFilePath, TerminateStatus);
                if (XenCenterNodeFound != null)
                {
                    // AutomationElement ServerNodeFound = GuiObj.GetTheTreeElement(XenCenterNodeFound, ServerName, LogFilePath);
                    AutomationElement ServerNodeFound = GuiObj.CheckTreeForElementAndClickIfReqd(XenCenterNodeFound, ServerName, 0, "0", LogFilePath);

                    if (ServerNodeFound == null)
                    {
                        NewLogObj.WriteLogFile(LogFilePath, "ServerNodeFound is null", "fail");
                        if (TerminateStatus == 1)
                        {
                            NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 1.", "info");
                            NewLogObj.WriteLogFile(LogFilePath, "***Exiting application from ConnectToXenserver as ConnecToServerTimeOut**", "fail");
                            FileOperations FileObj = new FileOperations();
                            FileObj.ExitTestEnvironment();
                        }
                        else
                        {
                            NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 0.", "info");
                        }
                    }


                    //PropertyCondition ServerNodeCondition = GuiObj.SetPropertyCondition("NameProperty", ServerName, 1, LogFilePath);
                    //AutomationElement ServerNodeFound = GuiObj.FindAutomationElement(XenCenterNodeFound, ServerNodeCondition, TreeScope.Descendants, "Server node", 0, LogFilePath);
                    ExpandCollapsePattern expPattern = ServerNodeFound.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern;
                    Thread.Sleep(1000);
                    string CurrentState = expPattern.Current.ExpandCollapseState.ToString();
                    NewLogObj.WriteLogFile(LogFilePath, "ServerNodeFound CurrentState " + CurrentState, "info");
                    if (string.Compare(CurrentState, "LeafNode") == 0)
                    {
                        NewLogObj.WriteLogFile(LogFilePath, "ServerNodeFound is leaf node ", "info");
                        GuiObj.GetPositionFromBoundingRectangleAndClick(ServerNodeFound, LogFilePath, "Left");
                        Thread.Sleep(3000);
                        Microsoft.Test.Input.Mouse.Click(Microsoft.Test.Input.MouseButton.Right);
                        Thread.Sleep(3000);
                        System.Windows.Forms.SendKeys.SendWait("c");
                        Thread.Sleep(1000);

                        //Check for Add new server window
                        PropertyCondition WindowReturnCondition   = GuiObj.SetPropertyCondition("AutomationIdProperty", "AddServerDialog", 1, LogFilePath);
                        AutomationElement ServerDialogObj         = GuiObj.FindAutomationElement(XenCenterObj, WindowReturnCondition, TreeScope.Descendants, "Add New Server Window", 1, LogFilePath);
                        PropertyCondition PasswordReturnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "PasswordTextBox", 1, LogFilePath);
                        AutomationElement PasswordTextBoxObj      = GuiObj.FindAutomationElement(ServerDialogObj, PasswordReturnCondition, TreeScope.Descendants, "PasswordTextBox", 1, LogFilePath);

                        GuiObj.SetTextBoxText(PasswordTextBoxObj, Password, "PasswordTextBox", 1, LogFilePath);

                        PropertyCondition AddBtnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "AddButton", 1, LogFilePath);
                        AutomationElement AddBtnObj       = GuiObj.FindAutomationElement(ServerDialogObj, AddBtnCondition, TreeScope.Descendants, "AddBtn", 0, LogFilePath);
                        GuiObj.ClickButton(AddBtnObj, 1, "AddBtn", 1, LogFilePath);

                        //PropertyCondition ConnecToServerDialogReturnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "ConnectingToServerDialog", 1, LogFilePath);
                        //AutomationElement ConnecToServerDialogObj = GuiObj.FindAutomationElement(XenCenterObj, ConnecToServerDialogReturnCondition, TreeScope.Descendants, "ConnectingToServerDialog", 1, LogFilePath);
                        //if (ConnecToServerDialogObj != null)
                        //{
                        NewLogObj.WriteLogFile(LogFilePath, "ConnecToServerDialogObj found ", "info");
                        int Timer = 0;
                        while ((string.Compare(CurrentState, "LeafNode") == 0) && (Timer < ConnecToServerTimeOut))
                        {
                            expPattern   = ServerNodeFound.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern;
                            CurrentState = expPattern.Current.ExpandCollapseState.ToString();
                            NewLogObj.WriteLogFile(LogFilePath, "ServerNodeFound CurrentState " + CurrentState, "info");
                            if (string.Compare(CurrentState, "LeafNode") == 0)
                            {
                                NewLogObj.WriteLogFile(LogFilePath, "Server still the leaf node ", "info");
                                Thread.Sleep(5000);
                                Timer = Timer + 5000;
                            }
                            else
                            {
                                NewLogObj.WriteLogFile(LogFilePath, "Server is not the leaf node. Server added successfully ", "info");

                                break;
                            }
                        }
                        if (Timer >= ConnecToServerTimeOut)
                        {
                            NewLogObj.WriteLogFile(LogFilePath, "ServerNodeFound is null even after wait of " + ConnecToServerTimeOut, "fail");
                            if (TerminateStatus == 1)
                            {
                                NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 1.", "info");
                                NewLogObj.WriteLogFile(LogFilePath, "***Exiting application from ConnectToXenserver as ConnecToServerTimeOut**", "fail");
                                FileOperations FileObj = new FileOperations();
                                FileObj.ExitTestEnvironment();
                            }
                            else
                            {
                                NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 0.", "info");
                            }
                        }
                        //}
                        //else
                        //{
                        //    NewLogObj.WriteLogFile(LogFilePath, "ConnecToServerDialogObj not found ", "fail");

                        //}
                    }
                    else
                    {
                        GuiObj.GetPositionFromBoundingRectangleAndClick(ServerNodeFound, LogFilePath, "Left");
                    }
                }
                else
                {
                    NewLogObj.WriteLogFile(LogFilePath, "ServerNodeFound is null at ConnectToXenserver", "fail");
                    if (TerminateStatus == 1)
                    {
                        NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 1.", "info");
                        NewLogObj.WriteLogFile(LogFilePath, "***Exiting application from ConnectToXenserver as main menunot found**", "fail");
                        FileOperations FileObj = new FileOperations();
                        FileObj.ExitTestEnvironment();
                    }
                    else
                    {
                        NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 0.", "info");
                    }
                }
            }
            catch (Exception Ex)
            {
                NewLogObj.WriteLogFile(LogFilePath, "Exception at ConnectToXenserver" + Ex.ToString(), "fail");
                if (TerminateStatus == 1)
                {
                    NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 1.", "info");
                    NewLogObj.WriteLogFile(LogFilePath, "***Exiting application from ConnectToXenserver as main menunot found**", "fail");
                    FileOperations FileObj = new FileOperations();
                    FileObj.ExitTestEnvironment();
                }
                else
                {
                    NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 0.", "info");
                }
            }
        }