//######################################################################################### // Check the Xencenter server node tree for an element //Will perform a click on the found element if 'Click' is set to 1. ClickMouseBtn should be either left or right. will simulate right or left click //######################################################################################### public AutomationElement CheckXenCenterServerNodetree(AutomationElement XenCenterObj, string ElementToCheck, string LogFilePath, int TerminateStatus, int ClickRequired, string ClickMouseBtn) { Logger NewLogObj = new Logger(); NewLogObj.WriteLogFile(LogFilePath, "CheckXenCenterServerNodetree", "info"); NewLogObj.WriteLogFile(LogFilePath, "=============================", "info"); AutomationElementIdentity GuiObj = new AutomationElementIdentity(); try { PropertyCondition TreeReturnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "treeView", 1, LogFilePath); AutomationElement ServerPane = GuiObj.FindAutomationElement(XenCenterObj, TreeReturnCondition, TreeScope.Descendants, "Server Paniewe V", 0, LogFilePath); PropertyCondition XenCenterParentCondition = GuiObj.SetPropertyCondition("NameProperty", "XenCenter", 1, LogFilePath); AutomationElement XenCenterParentElement = GuiObj.FindAutomationElement(ServerPane, XenCenterParentCondition, TreeScope.Descendants, "XenCenterParentElement", 0, LogFilePath); if (ClickRequired == 1) { int PatternSupport = GuiObj.CheckIfPatternIsSupported(XenCenterParentElement, "ExpandCollapse"); if (PatternSupport == 1) { ExpandCollapsePattern expPattern = XenCenterParentElement.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern; Thread.Sleep(1000); if (string.Compare(expPattern.Current.ExpandCollapseState.ToString(), "Collapsed") == 0) { expPattern.Expand(); } } } TestAPI TestApiObj = new TestAPI(); //TestApiObj.ClickLeftBtnOnAutomationElement(XenCenterParentElement, 1, LogFilePath); //AutomationElement SearchElement = GuiObj.GetTheTreeElement(XenCenterParentElement, ElementToCheck, LogFilePath); AutomationElement SearchElement = GuiObj.CheckTreeForElementAndClickIfReqd(XenCenterParentElement, ElementToCheck, 0, "0", LogFilePath); if (SearchElement != null && ClickRequired == 1) { //TestApiObj.ClickLeftBtnOnAutomationElement(SearchElement, 1, LogFilePath); //SelectionItemPattern SelectionPattern = SearchElement.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern; //SelectionPattern.Select(); GuiObj.GetPositionFromBoundingRectangleAndClick(SearchElement, LogFilePath, ClickMouseBtn); } if (SearchElement != null) { NewLogObj.WriteLogFile(LogFilePath, "SearchElement found", "info"); return(SearchElement); } else { NewLogObj.WriteLogFile(LogFilePath, "SearchElement returnd is null", "fail"); if (TerminateStatus == 1) { NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 1.", "info"); NewLogObj.WriteLogFile(LogFilePath, "***Exiting application from CheckXenCenterServerNodetree as SearchElement returnd is null**", "fail"); FileOperations FileObj = new FileOperations(); FileObj.ExitTestEnvironment(); return(null); } else { NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 0.", "info"); return(null); } } } catch (Exception Ex) { NewLogObj.WriteLogFile(LogFilePath, "Exception at ClickOnXenCenterNode" + Ex.ToString(), "fail"); if (TerminateStatus == 1) { NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 1.", "info"); NewLogObj.WriteLogFile(LogFilePath, "***Exiting application from ClickOnXenCenterNode as main menunot found**", "fail"); FileOperations FileObj = new FileOperations(); FileObj.ExitTestEnvironment(); return(null); } else { NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 0.", "info"); return(null); } } }