Quantcast
Channel: Windows Desktop Development for Accessibility and Automation forum
Viewing all articles
Browse latest Browse all 585

UIAutomation FindFirst Method is not working after upgrading 4.5.2 framework.Below is the code we are using

$
0
0

 Hello,

         We are using below method to find sub tree items. Able to find Main node but it is showing zero children in it. By using inspect tool Main node is showing like group and sub tree also able to see. We used name property to get sub child elements but tried using element collection also. It is also returning only main nodes. It happened after we upgrade our framework to 4.5.2.  

public static AutomationElement GetElementByNameFromDescendants(AutomationElement parentElement, string value)
        {
            return Utility.TryGetElement(() =>
            {
                return parentElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, value));
            }, 10, 1000);
        }

To get element collection:

 public static AutomationElement GetElementByPartialNameFromDescendants(AutomationElement element, string value)
        {
            AutomationElementCollection elementCollection =
             element.FindAll(TreeScope.Descendants, Condition.TrueCondition);
            int count = elementCollection.Count;
            for (int i = 0; i <= count - 1; i++)
            {
                if (elementCollection[i].Current.Name != null)
                {
                    if (elementCollection[i].Current.Name.IndexOf(value) >= 0)
                    {
                        return elementCollection[i];
                    }
                }
            }
            return null;
        }



Viewing all articles
Browse latest Browse all 585

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>