//************************************************************************************************************************************************************** public static void ClickTextInsidePanel(Window window, TestStack.White.UIItems.Panel pane, string text) { Logger.logMessage("Function call @ :" + DateTime.Now); try { Logger.logMessage("ClickTextInsidePanel " + window + "->" + pane + "->" + text); PropertyCondition textCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text); AutomationElementCollection textElements = pane.AutomationElement.FindAll(TreeScope.Descendants, textCondition); foreach (AutomationElement item in textElements) { if (item.Current.Name.Equals(text)) { var t = new TestStack.White.UIItems.Label(item, window.ActionListener); t.Focus(); t.Click(); Logger.logMessage("ClickTextInsidePanel " + window + "->" + pane + "->" + text + " - Successful"); Logger.logMessage("------------------------------------------------------------------------------"); break; } } } catch (Exception e) { Logger.logMessage("ClickTextInsidePanel " + window + "->" + pane + "->" + text + " - Failed"); Logger.logMessage(e.Message); Logger.logMessage("------------------------------------------------------------------------------"); String sMessage = e.Message; LastException.SetLastError(sMessage); throw new Exception(sMessage); } }
//************************************************************************************************************************************************************** public static void UIA_ClickTextByAutomationID(AutomationElement uiaWindow, Window window, string automationID) { Logger.logMessage("Function call @ :" + DateTime.Now); try { PropertyCondition textCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text); AutomationElementCollection texts = uiaWindow.FindAll(TreeScope.Descendants, textCondition); foreach (AutomationElement e in texts) { if (e.Current.AutomationId.Equals(automationID)) { TestStack.White.UIItems.Label t = new TestStack.White.UIItems.Label(e, window.ActionListener); t.Click(); } } Thread.Sleep(int.Parse(Execution_Speed)); Logger.logMessage("UIA_ClickTextByAutomationID " + uiaWindow + "->" + window + "->" + automationID + " - Successful"); Logger.logMessage("------------------------------------------------------------------------------"); } catch (Exception e) { Logger.logMessage("UIA_ClickTextByAutomationID " + uiaWindow + "->" + window + "->" + automationID + " - Failed"); Logger.logMessage(e.Message); Logger.logMessage("------------------------------------------------------------------------------"); String sMessage = e.Message; LastException.SetLastError(sMessage); throw new Exception(sMessage); } }