カスタム コントロールの 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 がインストールされているコンピューターと、テスト エージェントがインストールされている他のコンピューターで、コードを使用して testmethod を開始しました。
AutomationPattern[] supportedPatterns = customControl.GetSupportedPatterns();
foreach (var supPattern in supportedPatterns)
Trace.WriteLine(supPattern.ProgrammaticName);
トレースの結果:
ビジュアルスタジオを搭載したコンピューターで:
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
2 番目のケースで IGridProvider しか取得できないのはなぜですか?