語言

AutomationElement.AutomationElementInformation.AutomationId 屬性

定義

會取得包含該元素 UI 自動化識別碼(ID)的字串。

public:
 property System::String ^ AutomationId { System::String ^ get(); };
public string AutomationId { get; }
member this.AutomationId : string
Public ReadOnly Property AutomationId As String

屬性值

一個元素在其容器內兄弟姊妹中獨一無二的 ID。

備註

當元素可用 AutomationIdProperty 時,無論本地語言為何,該元素在任何應用程式實例中都應始終相同。 這個值應該在兄弟元件間是唯一的,但不一定要在整個桌面上唯一。 例如,應用程式的多個實例,或 Microsoft Windows 檔案總管中的多個資料夾檢視,可能包含具有相同 AutomationIdProperty 的元素,例如「SystemMenuBar」。

雖然支持一個 AutomationId 以提升測試穩定性是建議的,但此特性並非強制。 在支援的情況下,an AutomationId 對於建立不依賴 UI 語言都能執行的測試自動化腳本非常有用。 用戶端不應對其他應用程式所暴露的 s 做任何假設 AutomationId。 An AutomationId 不一定能在不同版本或版本中穩定。

如需詳細資訊,請參閱AutomationIdProperty。

適用於