我不觉得,因为它不是一个自动化属性,但你可以做的是定义你可以访问使用白色数据项的标记属性您的数据项的属性HelpText中的测试值。
...
myTreeViewItem.SetValue(AutomationProperties.HelpText, "MyValueForAutomation");
...
然后在你的自动化代码,你可以这样
Application application = Application.Attach("WpfTestApplication1");
var window = application.GetWindow("MainWindow");
var yourTree = window.Get<Tree>("MyTestTree");
var treeRoot = yourTree.Nodes.FirstOrDefault();
treeRoot.Select();
treeRoot.Expand();
foreach (TreeNode node in treeRoot.Nodes)
{
object help = node.AutomationElement.GetCurrentPropertyValue(AutomationElement.HelpTextProperty, true);
if(help != AutomationElement.NotSupported)
{
string helpText = (string)help;
}
}
检索