AutomationElement.AutomationIdProperty フィールド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
要素を識別するために使用される AutomationId プロパティを識別します。
public: static initonly System::Windows::Automation::AutomationProperty ^ AutomationIdProperty;
public static readonly System.Windows.Automation.AutomationProperty AutomationIdProperty;
staticval mutable AutomationIdProperty : System.Windows.Automation.AutomationProperty
Public Shared ReadOnly AutomationIdProperty As AutomationProperty
フィールド値
例
次の例では、プロパティの現在の値を取得します。 要素に既定値が指定されていない場合は、既定値が返されます。
string autoId =
autoElement.GetCurrentPropertyValue(AutomationElement.AutomationIdProperty) as string;
Dim autoId As String = _
CStr(autoElement.GetCurrentPropertyValue(AutomationElement.AutomationIdProperty))
次の例では、プロパティの現在の値を取得しますが、要素自体がプロパティの値を提供しない場合は、既定値ではなく NotSupported を返すように指定します。
string autoIdString;
object autoIdNoDefault =
autoElement.GetCurrentPropertyValue(AutomationElement.AutomationIdProperty, true);
if (autoIdNoDefault == AutomationElement.NotSupported)
{
// TODO Handle the case where you do not wish to proceed using the default value.
}
else
{
autoIdString = autoIdNoDefault as string;
}
Dim autoIdString As String
Dim autoIdNoDefault As Object = autoElement.GetCurrentPropertyValue(AutomationElement.AutomationIdProperty, True)
If autoIdNoDefault Is AutomationElement.NotSupported Then
' TODO Handle the case where you do not wish to proceed using the default value.
Else
autoIdString = CStr(autoIdNoDefault)
End If
注釈
この識別子は、クライアント アプリケーションUI オートメーション使用されます。 UI オートメーションプロバイダーは、AutomationElementIdentifiers で同等の識別子を使用する必要があります。
このプロパティは、 Current または Cached プロパティから取得することもできます。
プロパティの戻り値は、 String型です。 プロパティの既定値は空の文字列です。
使用できる場合、要素の AutomationIdProperty は、ローカル言語に関係なく、アプリケーションの任意のインスタンスで常に同じである必要があります。 値は兄弟要素間で一意である必要がありますが、デスクトップ全体で一意であるとは限りません。 たとえば、アプリケーションの複数のインスタンスや、Microsoft Windows Explorer の複数のフォルダー ビューには、同じAutomationIdPropertyを持つ要素 ("SystemMenuBar" など) が含まれている場合があります。
テスト容易性を高めるには常に AutomationId のサポートをお勧めしますが、このプロパティは必須ではありません。 サポートされている場合、 AutomationId は、UI 言語に関係なく実行されるテスト自動化スクリプトを作成する場合に便利です。 クライアントは、他のアプリケーションによって公開される AutomationIdに関する想定を行うべきではありません。 AutomationIdは、アプリケーションの異なるリリースまたはビルド間で安定するとは限りません。
ユーザー インターフェイス (UI) 要素のインスタンスは、 RuntimeIdProperty プロパティによってデスクトップ上で一意に識別されます。
Note
AutomationIdProperty は、最上位レベルのアプリケーション ウィンドウ、WINDOWS Presentation Foundation (WPF) コントロールから派生した ID または x:Uid を持たない UI オートメーション要素、およびコントロール ID を持たない Win32 コントロールから派生した UI オートメーション要素を除く、コントロール ビュー内のすべての UI オートメーション要素でサポートされています。