繁体   English   中英

UI自动化:如何触发树项目的双击事件?

[英]UI Automation: How to trigger a tree item's double click event?

我想用Microsoft UI自动化测试应用程序,却陷入了触发树项的双击事件的困境。

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>))

child对象是有问题的树项目,但是它仅提供ExpandCollapsePatternSelectionItemPattern ,它们都对触发双击事件没有帮助。

我试图扩展此项目,以便可能以这种方式触发双击事件,但是我只有一个错误消息,告诉我无法扩展。

那么,我想念什么?

提前非常感谢您。

我已经通过免费的Microsoft.TestAPI库做到了这一点,我通过这个问题找到了该库。

给定一个自动化元素,我该如何模拟单击鼠标左键

            using Microsoft.Test.Input;

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

从Windows.Point转换为Drawing.Point可能是一种更好的方法,但是上面的方法对我有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM