有没有办法在TestStack.White中获取自定义控件类型内的所有元素

时间:2018-08-31 12:55:58

标签: c# wpf ui-automation

我刚刚使用WPF Framework在Visual Studio中创建了一个桌面应用程序,并且我的应用程序包含许多自定义控件类型。该应用程序的目的是学习使用TestStack.White的自动化。

除自定义控件类型外,大多数这些我都可以自动化。实际的问题是,我无法在自定义控件中获取元素。在谷歌搜索时,我发现类似

CustomUIItem customControl = item as CustomUIItem;
IUIItem[] items = customControl.AsContainer().GetMultiple(SearchCriteria.All);

但是对于我的C#代码,customControl.AsContainer()无法正常工作。我不知道是否是因为任何版本依赖性。因此,如果有人知道将AsContainer()与TestStack.White中的自定义控件类型一起使用的方法,请帮忙。

1 个答案:

答案 0 :(得分:0)

如果我正确理解了您的问题,那么您应该能够做到

CustomUIItem customControl = item as CustomUIItem;
IUIItem[] items = customControl.GetMultiple(SearchCriteria.All);

this SO question回答

相关问题