[英]Getting IUIItem[] for children of CustomUIItem in TestStack.White
WPF应用程序正在使用应用程序框架,而我都不能编辑它们。
我可以按照以下步骤访问GUI中的每个元素:
IUIItem[] items = window.GetMultiple(SearchCriteria.All);
foreach (var item in items)
{
visit((dynamic)item);
}
我对常规控件没有任何问题,但是我遇到了CustomUIItem
。
我想访问它的所有子项,但是无法从中创建一个新的数组IUIItem[]
。
这是我现在所拥有的:
void visit(CustomUIItem item)
{
AutomationElementCollection children =
item
.AutomationElement
.FindAll(TreeScope.Children, Condition.TrueCondition);
UIItemCollection temp = new UIItemCollection(children.Cast<AutomationElement>());
foreach(var t in temp)
{
visit((dynamic)t);
}
}
这样抛出的东西,大多数时间集合保持空白。
CusomControl
在其子CusomControl
具有“常规”控件。 我想要那些作为常规IUIItem
。
在哪里可以找到此文档。 我发现的唯一内容是this ,我无法做到这一点,因为我只是从外部访问,而且我不知道控件的内容。
如果我真的了解你的问题。
IUIItem[] items = window.GetMultiple(SearchCriteria.All);
foreach (var item in items)
{
visit(item);
}
我已经更新了您的visit()方法,现在它以IUItem作为参数来允许访问普通和自定义控件。
public void visit(IUIItem item)
{
if (item is CustomUIItem)
{
// Process custom controls
CustomUIItem customControl = item as CustomUIItem;
// Retrieve all the child controls
IUIItem[] items = customControl.AsContainer().GetMultiple(SearchCriteria.All);
// visit all the children
foreach (var t in items)
{
visit(t);
}
...
}
else
{
// Process normal controls
...
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.