public void CheckXenCenterInstalledVersion(string HelpMenu, string AboutXenCenterMenu, string XenCenterVersion) { Logger NewLogObj = new Logger(); string LogFilePath = NewLogObj.GetLogFilePath(); NewLogObj.WriteLogFile(LogFilePath, "CheckXenCenterInstalledVersion", "info"); NewLogObj.WriteLogFile(LogFilePath, "==============================", "info"); AutomationElementIdentity GuiObj = new AutomationElementIdentity(); XenCenter NewOprtorObj = new XenCenter(); FileOperations FileObj = new FileOperations(); NewOprtorObj.OpenXenCenter(LogFilePath); Thread.Sleep(2000); AutomationElement NewAutoObj = NewOprtorObj.SetFocusOnWindow(AutomationElement.RootElement, "NameProperty", "XenCenter", TreeScope.Children, "XenCenter", 1, LogFilePath); int WaitTimeOut = 300000;//5 mins int timer = 0; while (NewAutoObj == null && timer < WaitTimeOut) { NewAutoObj = NewOprtorObj.SetFocusOnWindow(AutomationElement.RootElement, "NameProperty", "XenCenter", TreeScope.Children, "XenCenter", 1, LogFilePath); Thread.Sleep(2000); timer = timer + 2000; NewLogObj.WriteLogFile(LogFilePath, "Waiting for Xencenter to open", "info"); Console.WriteLine("Waiting for Xencenter to open "); } if (NewAutoObj == null && timer >= WaitTimeOut) { Console.WriteLine("Timeout waiting for Xencenter to open after installation.Exiting.. "); NewLogObj.WriteLogFile(LogFilePath, "Timeout waiting for Xencenter to open after installation.Exiting.. ", "fail"); FileObj.ExitTestEnvironment(); } NewLogObj.WriteLogFile(LogFilePath, "Xencenter has opened after installation", "info"); Console.WriteLine("Xencenter has opened after installation "); //Check if periodic update cjheck window has come //Commenting for demo.. Remmber to uncomment ***************************************** //PropertyCondition AllowUpdateWindowCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "AllowUpdatesDialog", 1, LogFilePath); //AutomationElement AllowUpdatesDialog = GuiObj.FindAutomationElement(NewAutoObj, AllowUpdateWindowCondition, TreeScope.Children, "AllowUpdatesDialog", 0, LogFilePath); //WaitTimeOut = 60000;//1 mins //timer = 0; //while (AllowUpdatesDialog == null && timer < WaitTimeOut) //{ // AllowUpdatesDialog = GuiObj.FindAutomationElement(NewAutoObj, AllowUpdateWindowCondition, TreeScope.Children, "AllowUpdatesDialog", 0, LogFilePath); // Thread.Sleep(3000); // timer = timer + 3000; // NewLogObj.WriteLogFile(LogFilePath, "Waiting for AllowUpdatesDialog to open", "info"); // Console.WriteLine("Waiting for AllowUpdatesDialog to open "); //} //if (AllowUpdatesDialog == null && timer >= WaitTimeOut) //{ // Console.WriteLine("Timeout waiting for AllowUpdatesDialog to open after installation. "); // NewLogObj.WriteLogFile(LogFilePath, "Timeout waiting for AllowUpdatesDialog to open after installation. ", "fail"); // //Environment.Exit(1); //} //if (AllowUpdatesDialog != null) //{ // NewLogObj.WriteLogFile(LogFilePath, "AllowUpdatesDialog has opened after installation", "info"); // Console.WriteLine("AllowUpdatesDialog has opened after installation "); // NewLogObj.WriteLogFile(LogFilePath, "AllowUpdatesDialog found after installation", "info"); // PropertyCondition YesBtnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "YesButton", 1, LogFilePath); // AutomationElement YesBtnObj = GuiObj.FindAutomationElement(AllowUpdatesDialog, YesBtnCondition, TreeScope.Children, "YesBtn", 1, LogFilePath); // GuiObj.ClickButton(YesBtnObj, 1, "YesBtnObj", 1, LogFilePath); // Thread.Sleep(1000); //} //Commenting for demo.. Remmber to uncomment ***************************************** NewOprtorObj.InvokeXenCenterSubMenuItem(NewAutoObj, HelpMenu, AboutXenCenterMenu, LogFilePath, 1); Thread.Sleep(3000); PropertyCondition AboutDialogCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "AboutDialog", 1, LogFilePath); AutomationElement AboutDialogObj = GuiObj.FindAutomationElement(NewAutoObj, AboutDialogCondition, TreeScope.Children, "AboutDialog", 1, LogFilePath); PropertyCondition TblLayoutCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "tableLayoutPanel1", 1, LogFilePath); AutomationElement TblLayoutObj = GuiObj.FindAutomationElement(AboutDialogObj, TblLayoutCondition, TreeScope.Children, "AboutDialog", 1, LogFilePath); //Get the version PropertyCondition VersionLabelCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "VersionLabel", 1, LogFilePath); AutomationElement VersionLabelObj = GuiObj.FindAutomationElement(TblLayoutObj, VersionLabelCondition, TreeScope.Children, "AboutDialog", 1, LogFilePath); string VersionNumber = VersionLabelObj.Current.Name.ToString(); NewLogObj.WriteLogFile(LogFilePath, "VersionNumber found after install *" + VersionNumber + "*", "info"); NewLogObj.WriteLogFile(LogFilePath, "Expected VersionNumber XenCenterVersion *" + XenCenterVersion + "*", "info"); if (string.Compare(XenCenterVersion, VersionNumber) == 0) { NewLogObj.WriteLogFile(LogFilePath, "Right version of Xencenter installed " + VersionNumber, "pass"); } else { NewLogObj.WriteLogFile(LogFilePath, "Wrong version of Xencenter installed. Version found from Xenvcenter " + VersionNumber + "Version from inputs file " + XenCenterVersion, "fail"); } PropertyCondition OKBtnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "OkButton", 1, LogFilePath); AutomationElement OKBtnObj = GuiObj.FindAutomationElement(TblLayoutObj, OKBtnCondition, TreeScope.Children, "OKBtnObj", 1, LogFilePath); GuiObj.ClickButton(OKBtnObj, 1, "OKBtnObj", 1, LogFilePath); }
static void Main(string[] args) { XenCenter NewOprtorObj = new XenCenter(); Logger NewLogObj = new Logger(); NewLogObj.CreateLogFolder(); string LogFilePath = NewLogObj.CreateLogFile(); AutomationElementIdentity GuiObj = new AutomationElementIdentity(); Guizard NewGuiZardObj = new Guizard(); FileOperations FileObj = new FileOperations(); Generic GenericObj = new Generic(); XenServer XenObj = new XenServer(); // Session session =XenObj.Login("10.105.83.51", 80, "root", "citrix"); // XenObj.GetVMParam(session, "GSEN-Win7x86_29aug2012_1", "IP"); Generic NewGenericObj = new Generic(); //int ProcessStatus = NewGenericObj.CheckIfProcessIsRunning("GUIzard_3"); FileObj.FinishCurrentTest("MyTest"); //string cur = Thread.CurrentThread.CurrentCulture.Name; //CultureInfo us = new CultureInfo("zh-CN"); //string shortUsDateFormatString = us.DateTimeFormat.ShortDatePattern; // string shortUsTimeFormatString = us.DateTimeFormat.ShortTimePattern; // string LabelPanel1 = "General"; // string LabelPanel2 = "Custom Fields"; // string InputFilePath = FileObj.GetInputFilePath(LogFilePath, "Inputs.txt"); // string XenServerName = FileObj.GetInputPattern(InputFilePath, "AddedXenServerDisplayName"); // string ChangeHyperlink = "Change..."; // string EditTagsHyperlink = "Edit tags..."; // string LocalizedFilePath = FileObj.GetLocalizedFilePath(); // if (LocalizedFilePath != null) // { // LabelPanel1 = FileObj.GetLocalizedMappedPattern(LocalizedFilePath, LabelPanel1); // LabelPanel2 = FileObj.GetLocalizedMappedPattern(LocalizedFilePath, LabelPanel2); // ChangeHyperlink = FileObj.GetLocalizedMappedPattern(LocalizedFilePath, ChangeHyperlink); // EditTagsHyperlink = FileObj.GetLocalizedMappedPattern(LocalizedFilePath, EditTagsHyperlink); // } // AutomationElement XenCenterObj = NewOprtorObj.SetFocusOnWindow(AutomationElement.RootElement, "NameProperty", "XenCenter", TreeScope.Children, "XenCenter", 1, LogFilePath); // AutomationElement ServerObj = NewOprtorObj.CheckXenCenterServerNodetree(XenCenterObj, XenServerName, LogFilePath, 1, 1, "Right"); // // Open properties // System.Windows.Forms.SendKeys.SendWait("r"); // Thread.Sleep(2000); // AutomationElement PropertiesWindow=GenericObj.VerifyWindowOnScreen(XenCenterObj, "EditHostGeneralSettingsDialog", "TabTitle", LabelPanel1, 1); // PropertyCondition ParentListCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "verticalTabs", 1, LogFilePath); // AutomationElement ParentListObj = GuiObj.FindAutomationElement(PropertiesWindow, ParentListCondition, TreeScope.Descendants, "ParentListCondition", 1, LogFilePath); // //Select customfields tab // //GuiObj.SelectItemFromParent(ParentListObj, LabelPanel2, 1); //AutomationElement ListElement= GuiObj.GetListElementAndSelect(ParentListObj,1,3,LabelPanel2, 1); //System.Windows.Point ClickablePoint = ListElement.GetClickablePoint(); //System.Drawing.Point p = new System.Drawing.Point(Convert.ToInt32(ClickablePoint.X), Convert.ToInt32(ClickablePoint.Y)); //Microsoft.Test.Input.Mouse.MoveTo(p); // Thread.Sleep(2000); //Microsoft.Test.Input.Mouse.Click(Microsoft.Test.Input.MouseButton.Left); // NewGuiZardObj.VerifyGuiZardResults(); //NewGuiZardObj.KillGuizard(); System.Console.WriteLine("Finsihed"); //string LogFilePath = NewLogObj.GetLogFilePath(); //NewGuiZardObj.VerifyGuiZardHasFinishedCapturing(AddServerDialog, "AddServerDialog"); //string AddServerDialog = "Add New Server"; //string LocalizedFilePath = FileObj.GetLocalizedFilePath(); //if (LocalizedFilePath != null) //{ // AddServerDialog = FileObj.GetLocalizedMappedPattern(LocalizedFilePath, AddServerDialog); //} //NewGuiZardObj.VerifyGuiZardHasFinishedCapturing(AddServerDialog, "AddServerDialog"); }