Я написал класс AutomationPeer для своего пользовательского элемента управления:
// Automation Peer for the CustomControl
private class CustommControlAutomationPeer : FrameworkElementAutomationPeer, IValueProvider, IGridProvider
{
public CustomControlAutomationPeer(CustomControl control)
: base(control)
{ }
#region overriding the "Core" methods from the base automation peer class that describe behavior unique and specific to custom control
...
#endregion
#region overriding of GetPattern should return the object that implements the specified pattern
public override object GetPattern(PatternInterface patternInterface)
{
if (patternInterface == PatternInterface.Grid || patternInterface == PatternInterface.Value)
{
return this;
}
return base.GetPattern(patternInterface);
}
#endregion
#region IGridProvider
...
#endregion
#region IValueProvider
...
#endregion
/// <summary>
/// Pointer to CustomControl
/// </summary>
private CustomControl Control
{
get
{
return (CustonControl)base.Owner;
}
}
}
На компьютере, где установлен Visual Studio, и на другом компьютере, где установлен агент тестирования, я запустил метод тестирования с кодом:
AutomationPattern[] supportedPatterns = customControl.GetSupportedPatterns();
foreach (var supPattern in supportedPatterns)
Trace.WriteLine(supPattern.ProgrammaticName);
Результат трассировки:
на компьютере с Visual Studio:
QTAgent32.exe, <a class=success>Playback - {43} [SUCCESS] MouseButtonClick - "[UIA]ControlType='RadioButton' && AutomationId='allCriteriaRadioButton'"
\0</a>
**ValuePatternIdentifiers.Pattern;
GridPatternIdentifiers.Pattern**
QTAgent32.exe, IEDOM : StopSession of the plugin called before StartSession
QTAgent32.exe, UIA : StopSession of the plugin called before StartSession
на компьютере с тестовым агентом:
QTAgent32.exe, <a class=success>Playback - {43} [SUCCESS] MouseButtonClick - "[UIA]ControlType='RadioButton' && AutomationId='allCriteriaRadioButton'"
\0</a>
**GridPatternIdentifiers.Pattern**
QTAgent32.exe, IEDOM : StopSession of the plugin called before StartSession
QTAgent32.exe, UIA : StopSession of the plugin called before StartSession
Почему я получаю только IGridProviderвторой случай?