TestStack.White-使用SearchCriteria.ByNativeProperty

时间:2019-05-10 07:54:54

标签: c# teststack automationelement

使用UI Spy分析,我想要获得以下元素: enter image description here

查看所有此参数,“ 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。

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

0 个答案:

没有答案