首页 > 解决方案 > TestStack.White - 使用 SearchCriteria.ByNativeProperty

问题描述

用 UI Spy 分析,我想得到以下元素: 在此处输入图像描述

查看所有这些参数,“LabeledBy”参数似乎是识别元素的最佳参数。我正在使用 TestStack.White 进行自动化并以这种方式进行了尝试:

TestStack.White.UIItems.IUIItem[] IUIArr = GetMainWindow().GetMultiple(TestStack.White.UIItems.Finders.SearchCriteria.ByNativeProperty(System.Windows.Automation.AutomationElement.LabeledByProperty, NUnit.Framework.Is.EqualTo(TestStack.White.UIItems.Finders.SearchCriteria.ByNativeProperty(System.Windows.Automation.AutomationElement.NameProperty, "NLP*"))));

GetMainWindow()是一个函数,返回应用程序的 MainWindow 并且它工作正常。

我的主要问题是,我得到一个例外的文本Der PropertyCondition-Wert für die AutomationElementIdentifiers.LabeledByProperty-Eigenschaft muss "AutomationElement" sein是什么意思翻译的东西The value for property condition of an AutomationElementIdentifier.LabeledByPropery has to bei "AutomationElement"

我的第二个但不是很重要的问题是:我真的只需要为那个 Is.EqualTo-Function 引用 NUnit 吗?通常我会尽量避免引用外部 DLL,只针对一种方法。

不幸的是,我对使用 nativSystem.Windows.Automation库不是很熟练,但是没有 TestStack.White 的解决方案也会有所帮助。

标签: c#teststackautomationelement

解决方案


推荐阅读