我目前通过分别实施IRawElementProviderFragmentRoot
和IRawElementProviderFragment
向窗格控件和子控件添加UIA支持。
UIA片段使用方法public object GetPropertyValue(int propertyId)
将特定属性返回到Ranorex或Test Complete等测试记录器。例如:
/// <summary>
/// Retrieves the value of a property supported by the UI Automation provider.
/// </summary>
/// <param name="propertyId"></param>
/// <returns></returns>
public object GetPropertyValue(int propertyId)
{
if (propertyId == AutomationElementIdentifiers.NameProperty.Id)
{
// Name of this control. Since this is a top level pane, we'll use the partition name
return View.Document.FullName;
}
else if (propertyId == AutomationElementIdentifiers.ControlTypeProperty.Id)
{
// Pane controls represent a level of grouping lower than windows or documents, but above individual controls.
// The user can navigate between panes and within contents of the current pane, but cannot navigate between items in
// different panes. The pane navigation shortcut is typically CTRL + TAB.
return ControlType.Pane.Id;
}
else if (propertyId == AutomationElementIdentifiers.IsContentElementProperty.Id)
{
// Indicates whether the element contains content that is valuable to the end user
return true;
}
else if (propertyId == AutomationElementIdentifiers.IsControlElementProperty.Id)
{
// Indicates whether the element is viewed as a control
return true;
}
else if (propertyId == AutomationElementIdentifiers.IsKeyboardFocusableProperty.Id)
{
// You can't explicitly focus a tab, the whole window gets focused
return false;
}
else
{
// Null indicates no support
return null;
}
}
我希望注册一个自定义属性并在上面的方法中处理Get调用。根据此MSDN article,您的自定义属性可以返回
这正是我想要的。不幸的是,这些指令都是用C ++编写的,而且似乎并不是一个相应的C#程序集来完成这一切。我是否必须执行一些托管 - >非托管编组才能实现此目的?我该怎么做呢?
提前致谢!