UiPath Documentation
activities
latest
false
用户界面自动化活动
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。

关于选取器

用户界面自动化中的选取器:它们如何识别用户界面元素、标签结构、属性类型和最佳实践。

要自动执行用户界面中的特定操作,您需要与各种窗口、按钮、下拉列表以及许多其他元素交互。可以识别用户界面元素的一种方法是使用它们在屏幕上的位置,但这可能不可靠。

为了解决这个问题,Studio 使用了选取器。它们以 XML 片段的形式存储图形用户界面元素及其父元素的属性。

大多数情况下,选取器是由 Studio 自动生成的,并且不需要您额外输入,特别是当您尝试自动化的应用程序具有静态用户界面时。

然而,某些软件程序的布局会不断变化,且属性节点的值不稳定,例如某些网页应用程序。Studio 无法预测这些更改,因此,您可能必须手动生成一些选取器。

选取器具有以下结构:

<node_1/><node_2/>...<node_N/>
<node_1/><node_2/>...<node_N/>

最后一个节点表示您感兴趣的图形用户界面元素,而前面的所有节点都表示该元素的父元素。<node_1> 通常称为根节点,表示应用程序的顶部窗口。

每个节点都有一个或多个属性,可以帮助您正确识别所选应用程序的特定级别。

每个节点的格式如下:

<ui_system attr_name_1='attr_value_1' ... attr_name_N='attr_value_N'/>
<ui_system attr_name_1='attr_value_1' ... attr_name_N='attr_value_N'/>

每个属性都有一个赋值。重要的是选择具有常量值的属性。如果每次应用程序启动时,属性的值都会发生变化,则选取器将无法正确识别元素。

系统会在活动“属性”面板中的“输入”>“目标”>“选取器”下现实选取器。与图形元素相关的所有活动都具有此属性。

“选择选项”窗口用于选择和编辑目标。要访问此窗口,请在“工作流设计器”面板中单击“选项”docs image按钮,然后选择在屏幕上指定目标或编辑目标。

“选取器编辑器”窗口用于查看自动生成的选取器以及编辑该选取器及其属性。要访问此窗口,请使用省略号按钮,该按钮位于“属性”面板中的“选取器”字段旁边。

选项

描述

验证

该按钮通过检查选取器定义的有效性以及目标元素在屏幕上的可见性来显示选取器的状态。

验证按钮具有三种状态:

  • 文档图像 正在验证选取器
  • 文档图像 有效选取器
  • 文档图像 无效选取器
  • 文档图像 修改的选取器,重新验证

该按钮与用户界面探测器验证状态相关。

指出元素

指出一个新的用户界面元素以替换前一个。

修复

使您能够重新指定相同的目标用户界面元素并修复选取器。此操作并不完全替换以前的选取器。只有在选取器无效时,该按钮才可用。

高亮显示

将目标元素置于前台。高亮显示一直持续到该选项被单击禁用为止。仅当选取器有效时才会启用该按钮。

编辑属性

包含标识目标应用程序时所需的所有应用程序组件(窗口、按钮等)。该部分可以编辑。

编辑选取器

保存实际的选取器。该部分可以编辑。

在用户界面探测器中打开

启动用户界面探测器。该选项仅对有效的选取器启用。

备注:

在某些情况下,当以不同的提升权限打开 Studio 和目标应用程序时,选取器可能无法工作。我们建议始终以相同的权限打开这两个应用程序。

支持的标签和属性​

下表列出了用于构建选取器和选取器功能的标签和属性之间的兼容性。

在 macOS 上,选取器类型 wnd、ax、java 和 sap 可用于不同用例:

  • AX 选取器可用于所有类型的 macOS 桌面应用程序。

  • SAP 选取器可用于 macOS 上的 SAP GUI for Java,需要启用脚本功能的 SAP 服务器。这些选取器对 SAP 应用程序最稳定,提供最全面的功能,例如提取表格数据。

  • Java 选取器可用于 Java 应用程序。由于 SAP GUI for Java 也是一个基于 Java 的应用程序,因此可以使用 Java 选择策略从默认选取器切换,以获取 Java 选取器。

    备注:

    Selectors generated for Java applications which contain multiple WND tags cannot be used with events monitoring.

WND​

属性模糊正则表达式区分大小写操作系统
app✅✅✅MacOS
cls✅✅✅Windows
title✅✅✅MacOS
aaname✅✅✅Windows
ctrlname (WinForms)✅✅✅Windows
ctrlid (WinForms)✅✅✅Windows
idx❌❌❌MacOS
tid❌❌❌MacOS
pid❌❌❌MacOS
isremoteapp❌❌❌Windows
aastate✅✅✅Windows
角色✅✅✅macOS
enabled✅✅✅macOS
focused✅✅✅macOS
已选定✅✅✅macOS
已展开✅✅✅macOS
sapClient (SAP)✅✅✅MacOS
sapLanguage (SAP)✅✅✅MacOS
sapProgram (SAP)✅✅✅MacOS
sapScreen (SAP)❌❌❌MacOS
sapSession (SAP)❌❌❌MacOS
sapSysName (SAP)✅✅✅MacOS
sapSysNumber (SAP)❌❌❌MacOS
sapSysSessionId (SAP)✅✅✅MacOS
sapTransaction (SAP)✅✅✅MacOS
sapUser (SAP)✅✅✅MacOS
curlApplet(Curl)✅✅✅Windows

HTML​

属性模糊正则表达式区分大小写操作系统
url✅✅✅Windows 操作系统 Linux
htmlwindowname✅✅✅Windows 操作系统 Linux
title✅✅✅Windows 操作系统 Linux
class✅✅✅Windows 操作系统 Linux
app❌❌❌Windows 操作系统 Linux
idx❌❌❌Windows 操作系统 Linux
pid❌❌❌Windows 操作系统 Linux
tid❌❌❌Windows 操作系统 Linux
excludehwnd❌❌❌Windows 操作系统 Linux
bsid (Browser Session ID)❌❌❌Windows 操作系统 Linux
isremoteapp❌❌❌Windows 操作系统 Linux

WEBCTRL​

tag 和 idx 属性使用字符串值。所有其他 WEBCTRL 属性都具有动态值。

属性模糊正则表达式区分大小写操作系统
tag✅✅✅Windows 操作系统 Linux
idx✅✅✅Windows 操作系统 Linux
aaname✅✅✅Windows 操作系统 Linux
name✅✅✅Windows 操作系统 Linux
id✅✅✅Windows 操作系统 Linux
parentid✅✅✅Windows 操作系统 Linux
class✅✅✅Windows 操作系统 Linux
css-selector❌❌❌Windows 操作系统 Linux
innertext✅✅✅Windows 操作系统 Linux
visibleinnertext✅✅✅Windows 操作系统 Linux
isleaf✅✅✅Windows 操作系统 Linux
parentclass✅✅✅Windows 操作系统 Linux
parentname✅✅✅Windows 操作系统 Linux
src✅✅✅Windows 操作系统 Linux
href✅✅✅Windows 操作系统 Linux
tableCol✅✅✅Windows 操作系统 Linux
tableRow✅✅✅Windows 操作系统 Linux
colName✅✅✅Windows 操作系统 Linux
rowName✅✅✅Windows 操作系统 Linux
aria-label✅✅✅Windows 操作系统 Linux
aria-labelledby✅✅✅Windows 操作系统 Linux

CTRL​

属性模糊正则表达式区分大小写操作系统
角色✅✅✅Windows
name✅✅✅Windows
automationid✅✅✅Windows
labeledby✅✅✅Windows
aastate✅✅✅Windows
virtualname✅✅✅Windows
text✅✅✅Windows
rowName✅✅✅Windows
idx❌❌❌Windows

UIA​

属性模糊正则表达式区分大小写操作系统
accelkey (Accelerator Key)✅✅✅Windows
acskey (Access Key)✅✅✅Windows
automationid✅✅✅Windows
cls✅✅✅Windows
helpText✅✅✅Windows
legacyAccHelp (Legacy Accessible Help)✅✅✅Windows
enabled✅✅✅Windows
kbfocus (Is Keyboard Focusable)✅✅✅Windows
ispwd (Is Password)✅✅✅Windows
itemstatus✅✅✅Windows
itemtype✅✅✅Windows
rtid (Runtime ID)✅✅✅Windows
角色✅✅✅Windows
name✅✅✅Windows
pid✅✅✅Windows
tableRow❌❌❌Windows
tableCol❌❌❌Windows
rowName✅✅✅Windows
colName✅✅✅Windows
idx❌❌❌Windows

Java​

属性模糊正则表达式区分大小写操作系统
角色✅✅✅MacOS
name✅✅✅MacOS
virtualname✅✅✅MacOS
javastate✅✅✅MacOS
tableRow❌❌❌MacOS
tableCol❌❌❌MacOS
rowName✅✅✅MacOS
colName✅✅✅MacOS
idx❌❌❌MacOS
cls✅✅✅MacOS
accessibleClass✅✅✅MacOS

SAP​

属性模糊正则表达式区分大小写操作系统
id✅✅✅MacOS
配合 ID此属性未在“属性”面板中公开,因为它与id属性互斥。可以手动添加。✅✅✅MacOS
tableRow❌❌❌MacOS
tableCol❌❌❌MacOS
colName✅✅✅MacOS
relpath✅✅✅MacOS
itemId✅✅✅MacOS

AX​

属性模糊正则表达式区分大小写操作系统
角色✅✅✅macOS
subrole✅✅✅macOS
name✅✅✅macOS
title✅✅✅macOS
标识符✅✅✅macOS
文件名✅✅✅macOS
url✅✅✅macOS
帮助✅✅✅macOS
enabled✅✅✅macOS
focused✅✅✅macOS
已选定✅✅✅macOS
已展开✅✅✅macOS
idx❌❌❌macOS
行计数❌❌❌macOS
列计数❌❌❌macOS
tableRow❌❌❌macOS
tableCol❌❌❌macOS
rowName✅✅✅macOS
colName✅✅✅macOS

cURL​

属性模糊正则表达式区分大小写操作系统
cls✅✅✅Windows
角色✅✅✅Windows
text✅✅✅Windows
title✅✅✅Windows
tableRow❌❌❌Windows
tableCol❌❌❌Windows
colHeader✅✅✅Windows
idx❌❌❌Windows

Silverlight​

请注意, Silverlight标记不支持“模糊” 、 “正则表达式”和“区分大小写”功能。

属性模糊正则表达式区分大小写操作系统
角色❌❌❌Windows
name❌❌❌Windows
text❌❌❌Windows
idx❌❌❌Windows

RDP​

RDP 标签用于远程自动化,其属性与 WND 标签相同。

属性模糊正则表达式区分大小写操作系统
app✅✅✅Windows
cls✅✅✅Windows
title✅✅✅Windows
aaname✅✅✅Windows
ctrlname (WinForms)✅✅✅Windows
ctrlid (WinForms)✅✅✅Windows
idx❌❌❌Windows
tid❌❌❌Windows
pid❌❌❌Windows
  • 支持的标签和属性​
  • WND​
  • HTML​
  • WEBCTRL​
  • CTRL​
  • UIA​
  • Java​
  • SAP​
  • AX​
  • cURL​
  • Silverlight​
  • RDP​

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新