1

I like to test an application with the Microsoft UI Automation and I got stuck in triggering a tree item's double click event.

Dim parent As AutomationElement
Dim child As AutomationElement

parent = <Code to retrieve parent element>

'expand the parent item
DirectCast(parent.GetCurrentPattern(ExpandCollapsePattern.Pattern), ExpandCollapsePattern).Expand()

'retrieve the child
child = parent.FindFirst(TreeScope.Descendants, New PropertyCondition(AutomationElement.NameProperty, <Name of the child element>))

This child object is the tree item in question, but it's only offering the ExpandCollapsePattern and the SelectionItemPattern, both of them are not helpful in triggering the double click event.

I tried to expand this item in order to maybe triggering the double click event that way, but I only got an error telling me that expanding is not possible.

So, what am I missing?

Thank you very much in advance.

Nostromo
  • 1,177
  • 10
  • 28

1 Answers1

0

I've managed to do this via the free Microsoft.TestAPI library, which I found through this question.

Given an Automation Element how do i simulate a single left click on it

            using Microsoft.Test.Input;

            var p = myTreeNode.GetClickablePoint();
            Mouse.MoveTo(new Point((int)p.X, (int)p.Y));
            Mouse.DoubleClick(MouseButton.Left);

There's probably a better way to convert from a Windows.Point to a Drawing.Point, but the above works for me.

Robin Bennett
  • 3,192
  • 1
  • 8
  • 18