private void FindMatchingDescendants(AutomationElement element, AutomationSearchCondition automationSearchCondition, ElementSearchResult elementSearchResult, int depth) { if (depth == 0) { return; } logger.DebugFormat("[RawSearch] Finding descendants of: ({0})", element.Display()); AutomationElement current = RawViewWalker.GetFirstChild(element); while (current != null) { MatchElement(current, automationSearchCondition, elementSearchResult); if (elementSearchResult.AllResultsFound) { return; } FindMatchingDescendants(current, automationSearchCondition, elementSearchResult, depth - 1); if (elementSearchResult.AllResultsFound) { return; } current = RawViewWalker.GetNextSibling(current); } }
private void MatchElement(AutomationElement current, AutomationSearchCondition automationSearchCondition, ElementSearchResult elementSearchResult) { logger.DebugFormat("[RawSearch] Matching: ({0})", current.Display()); if (automationSearchCondition.Satisfies(current)) { logger.DebugFormat("[RawSearch] Matched: ({0})", current.Display()); elementSearchResult.Add(current); } }
private void FindMatchingDescendants(AutomationElement element, AutomationSearchCondition automationSearchCondition, ElementSearchResult elementSearchResult, int depth) { if (depth == 0) { return; } logger.DebugFormat("[RawSearch] Finding descendants of: ({0})", element.Display()); AutomationElement current = RawViewWalker.GetFirstChild(element); while (current != null) { MatchElement(current, automationSearchCondition, elementSearchResult); if (elementSearchResult.AllResultsFound) return; FindMatchingDescendants(current, automationSearchCondition, elementSearchResult, depth - 1); if (elementSearchResult.AllResultsFound) return; current = RawViewWalker.GetNextSibling(current); } }
private ElementSearchResult FindAll(AutomationSearchCondition automationSearchCondition, ElementSearchResult elementSearchResult, int depth) { logger.DebugFormat("[RawSearch] Finding in: ({0})", automationElement.Display()); FindMatchingDescendants(automationElement, automationSearchCondition, elementSearchResult, depth); return(elementSearchResult); }
public virtual List <AutomationElement> Descendants(AutomationSearchCondition automationSearchCondition) { return(FindAll(automationSearchCondition, ElementSearchResult.ForMany(), CoreAppXmlConfiguration.Instance.MaxElementSearchDepth).Elements); }
public virtual AutomationElement Descendant(AutomationSearchCondition automationSearchCondition) { return (FindAll(automationSearchCondition, ElementSearchResult.ForOne(), CoreAppXmlConfiguration.Instance.MaxElementSearchDepth).Elements.FirstOrDefault ()); }
public virtual AutomationElement Child(AutomationSearchCondition automationSearchCondition) { return(FindAll(automationSearchCondition, ElementSearchResult.ForOne(), 1).Elements.FirstOrDefault()); }
private ElementSearchResult FindAll(AutomationSearchCondition automationSearchCondition, ElementSearchResult elementSearchResult, int depth) { logger.DebugFormat("[RawSearch] Finding in: ({0})", automationElement.Display()); FindMatchingDescendants(automationElement, automationSearchCondition, elementSearchResult, depth); return elementSearchResult; }