Beispiel #1
0
 public ATS GetElements(string TreeScope = null, string Name = null, string AutomationId = null, string ClassName = null, string FrameworkId = null, string ControlType = null)
 {
     try
     {
         System.Windows.Automation.TreeScope treeScope = GetTreeScope(TreeScope);
         System.Windows.Automation.Condition condition = GetCondition(Name, AutomationId, ClassName, FrameworkId, ControlType);
         me = me == null ? AutomationElement.RootElement : me;
         AutomationElementCollection aec = me.FindAll(treeScope, condition);
         AT[] at = new AT[aec.Count];
         for (int i = 0; i < aec.Count; i++)
         {
             at[i] = new AT(aec[i]);
         }
         return(new ATS(at));
     }
     catch (Exception ex)
     {
         throw new Exception("GetElements error. " + ex.Message);
     }
 }
Beispiel #2
0
 public AT GetElement(string TreeScope = null, string Name = null, string AutomationId = null, string ClassName = null, string FrameworkId = null, string ControlType = null, string Index = null, string Timeout = null, string IsEnabled = null)
 {
     try
     {
         AT atObj = null;
         this.me = (this.me == null) ? AutomationElement.RootElement : this.me;
         System.Windows.Automation.TreeScope treeScope = GetTreeScope(TreeScope);
         System.Windows.Automation.Condition condition = GetCondition(Name, AutomationId, ClassName, FrameworkId, ControlType);
         if (WaitProcessEventDelegate != null && !String.IsNullOrEmpty(Timeout))
         {
             Timeout = null;
         }
         AT.Ele.me = me; AT.Ele.condition = condition; AT.Ele.treeScope = treeScope; AT.Ele.Name = Name; AT.Ele.AutomationId = AutomationId; AT.Ele.ClassName = ClassName; AT.Ele.Index = Index;
         if (String.IsNullOrEmpty(Timeout))
         {
             atObj = this.GetElementHandle();
         }
         else
         {
             WaitProcessEventDelegate += new AT.WaitProcessDelegateHandler(EventDo_GetElementTimeout);
             atObj = GetElementAndWaitProcess(new AT(), Timeout);
         }
         if (!String.IsNullOrEmpty(IsEnabled))
         {
             if (!(atObj.GetElementInfo().IsEnabled()))
             {
                 throw new Exception("Not Enabled. ");
             }
         }
         return(atObj);
     }
     catch (Exception ex)
     {
         throw new Exception("GetElement error. " + ex.Message);
     }
 }