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 以提高可测试性,但此属性并非必需。 在支持的情况下, AutomationId 对于创建无论 UI 语言如何运行的测试自动化脚本都很有用。 客户端不应对 AutomationId由其他应用程序公开的 做出任何假设。 AutomationId不一定保证在应用程序的不同版本或内部版本中保持稳定。

有关详细信息,请参阅 AutomationIdProperty

适用于