System.Windows.Automation.TreeWalker.GetFirstChild C# (CSharp) Method

GetFirstChild() public method

public GetFirstChild ( AutomationElement element ) : AutomationElement
element AutomationElement
return AutomationElement
        public AutomationElement GetFirstChild(AutomationElement element)
        {
            return GetFirstChild(element, CacheRequest.Current);
        }

Same methods

TreeWalker::GetFirstChild ( AutomationElement element, CacheRequest request ) : AutomationElement

Usage Example

        // Get the child element by its Name/AutomationId
        //
        public IElement GetChild(string identifier)
        {
            Log.LogMessage("Looking for child '" + identifier+ "' of '" + this.ae.Current.Name + "'.");

            var walker = new TreeWalker(this.GenerateOrCondition(identifier));
            var currentElement = walker.GetFirstChild(this.ae);

            // Throw exception if element was not found correctly.
            //
            if (currentElement == null)
            {
                throw new ChildNotFoundException("Child '" + identifier + "' not found for parent '" +
                    this.ae.Current.Name + "'.");
            }

            return Factories.ElementFactory.GetIElementFromBase(currentElement);
        }
All Usage Examples Of System.Windows.Automation.TreeWalker::GetFirstChild