Using UIAutomation, certain elements are not available through TreeWalker even though I can see them with Accessibility Insights.

Tony Eley 6 Reputation points
2022-12-15T12:33:28.437+00:00

Using UIAutomation, certain elements are not available through TreeWalker even though I can see them with Accessibility Insights.

271033-screenshot-2022-12-15-at-122131.png

As you can see in the image, the tab element has 3 child elements, pane and 2 tab items.

When I try to get the first child (e is the tab element).....

   Dim ee As AutomationElement = TreeWalker.ControlViewWalker.GetFirstChild(e)  
 

.....it returns the first tab item. I then try to get the next sibling......

ee = TreeWalker.ControlViewWalker.GetNextSibling(ee)

....and it returns the second tab item. If I then try to get the next sibling it comes back with nothing as expected.

So, for some reason it isn't returning me the pane element.

Any ideas please?

Thanks
Tony

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,772 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Tony Eley 6 Reputation points
    2022-12-15T19:06:25.857+00:00

    If anyone reads this question you may want to know that it looks like the System.Windows.Automation is apparently deprecated!!!!

    I am going to attempt to use the IUIAutomationElement COM interface instead!

    1 person found this answer helpful.
    0 comments No comments

  2. Tony Eley 6 Reputation points
    2022-12-15T12:42:58.01+00:00

    I've also tried the following to try and find the pane element but still no luck (mainUIA is the window element)....

        Dim e As AutomationElement = Nothing  
        Dim es As AutomationElementCollection = mainUIA.FindAll(TreeScope.Descendants, New PropertyCondition(AutomationElement.LocalizedControlTypeProperty, "pane"))  
        If es.Count > 0 Then  
            For x As Integer = 0 To es.Count - 1  
                e = es.Item(x)  
                If RTrim(e.Current.Name) = "Result" Then  
                    Exit For  
                End If  
            Next  
        End If
    
    0 comments No comments

  3. Tony Eley 6 Reputation points
    2022-12-15T20:18:45.887+00:00

    BOOOOOOOOM!

    I'm now getting all the elements I'm expecting.

    Hopefully someone else having the same issues finds this thread!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.