AutomationProperties.AutomationId 附加屬性

定義

取得或設定可唯一識別專案給 Microsoft UI 自動化的字串。

see GetAutomationId, and SetAutomationId
see GetAutomationId, and SetAutomationId
see GetAutomationId, and SetAutomationId

備註

當專案可供使用時, AutomationId 不論本機語言為何,在應用程式的任何實例中都必須相同。 值在同層級元素之間應該是唯一的,但不一定在整個桌面上是唯一的。 例如,應用程式多個實例或 Windows 檔案總管中的多個資料夾檢視可以包含具有相同 AutomationId 屬性的專案,例如 「SystemMenuBar」。

雖然一律建議對 AutomationId 的支援,以取得更佳的自動化測試支援,但這個屬性並非必要。 支援的位置, AutomationId 對於建立不論 UI 語言為何的測試自動化腳本都很有用。 用戶端不應 AutomationId 假設其他應用程式所公開的值。 AutomationId 不保證在應用程式的不同版本或組建之間保持穩定。

適用於

另請參閱