示例#1
0
        /// <inheritdoc />
        public override SHAutomationElement FindFirstWithOptions(TreeScope treeScope, ConditionBase condition,
                                                                 TreeTraversalOption traversalOptions, SHAutomationElement root)
        {
            var nativeFoundElement = NativeElement7.FindFirstWithOptions((UIA.TreeScope)treeScope, ConditionConverter.ToNative(Automation, condition), (UIA.TreeTraversalOptions)traversalOptions, SHAutomationElementConverter.ToNative(root));

            return(SHAutomationElementConverter.NativeToManaged(Automation, nativeFoundElement));
        }
 /// <summary>
 /// Finds the first matching element in the specified order.
 /// </summary>
 public SHAutomationElement FindFirstWithOptionsBase(TreeScope treeScope, ConditionBase condition,
                                                     TreeTraversalOption traversalOptions, SHAutomationElement root)
 {
     try
     {
         return(FrameworkAutomationElement.FindFirstWithOptions(treeScope, condition, traversalOptions, root));
     }
     catch (System.Runtime.InteropServices.COMException)
     {
         return(null);
     }
 }
        public ISHAutomationElement[] FindAllWithOptions(TreeScope treeScope, ConditionBase condition, TreeTraversalOption traversalOptions, SHAutomationElement root, TimeSpan timeout, bool waitUntilExists = true)
        {
            List <SHAutomationElement> elements = new List <SHAutomationElement>();

            bool getElements(bool shouldExist)
            {
                if (!elements.Any())
                {
                    elements = FindAllWithOptionsBase(treeScope, condition, traversalOptions, root).Where(x => x.FrameworkAutomationElement != null).ToList();
                }
                return(shouldExist ? elements.Any() : !elements.Any());
            }

            getElements(waitUntilExists);
            if (!elements.Any() && waitUntilExists && timeout.TotalMilliseconds > 0)
            {
                SHSpinWait.SpinUntil(() => getElements(true), timeout);
            }
            else if (elements.Any() && !waitUntilExists && timeout.TotalMilliseconds > 0)
            {
                SHSpinWait.SpinUntil(() => getElements(false), timeout);
            }
            if (elements != null && elements.Any())
            {
                return(elements.ToArray());
            }
            return(Array.Empty <SHAutomationElement>());
        }
 public ISHAutomationElement[] FindAllWithOptions(TreeScope treeScope, ConditionBase condition, TreeTraversalOption traversalOptions, SHAutomationElement root)
 {
     return(FindAllWithOptions(treeScope, condition, traversalOptions, root, TimeSpan.FromSeconds(20)));
 }
示例#5
0
 /// <summary>
 /// Finds the first matching element in the specified order.
 /// </summary>
 /// <param name="treeScope">A combination of values specifying the scope of the search.</param>
 /// <param name="condition">A condition that represents the criteria to match.</param>
 /// <param name="traversalOptions">Value specifying the tree navigation order.</param>
 /// <param name="root">An element with which to begin the search.</param>
 /// <returns>The found element or null if no element was found.</returns>
 public abstract SHAutomationElement FindFirstWithOptions(TreeScope treeScope, ConditionBase condition, TreeTraversalOption traversalOptions, SHAutomationElement root);