C# 如何返回自定义控件';UIS自动化中的属性?
我参考了下面的文章,并成功地实现了返回默认控件类型的属性(UIAutomation) 这是示例代码C# 如何返回自定义控件';UIS自动化中的属性?,c#,winforms,ui-automation,coded-ui-tests,C#,Winforms,Ui Automation,Coded Ui Tests,我参考了下面的文章,并成功地实现了返回默认控件类型的属性(UIAutomation) 这是示例代码 object IRawElementProviderSimple.GetPropertyValue(int propId) { if (propId == AutomationElementIdentifiers.NameProperty.Id) { return "Custom list control"; } else if (propId ==
object IRawElementProviderSimple.GetPropertyValue(int propId)
{
if (propId == AutomationElementIdentifiers.NameProperty.Id)
{
return "Custom list control";
}
else if (propId == AutomationElementIdentifiers.ControlTypeProperty.Id)
{
return ControlType.List.Id;
}
else if (propId == AutomationElementIdentifiers.IsContentElementProperty.Id)
{
return true;
}
else if (propId == AutomationElementIdentifiers.IsControlElementProperty.Id)
{
return true;
}
else
{
return null;
}
}
在上面的代码中,如果属性id是control type,我们可以返回System.Windows.Automation.ControlType中列出的默认ControlType
我已将其用于注册自定义属性。不幸的是,我无法实现这一点
但是我担心是否可以返回自定义控件的属性。您能提出您的想法吗?控件类型列表是预定义的,不能更改。您到底想做什么?我的要求是在编码的UI测试生成器中显示自定义属性。使用上述代码,默认属性(如HelpText属性、ControlName属性等)将仅显示在编码的UI测试生成器中。有什么办法吗?我不知道你说的“定制属性”是什么意思。财产清单也相当固定。也许你可以使用AriaPropertiesProperty,它是一种通用的属性包。自定义属性意味着我的控件的属性,如BackColor、ForeColor等等。我需要在测试生成器中公开这些属性。我希望你能了解我的情况嗨,西蒙,谢谢你的更新。你能告诉我原因吗?