获取表信息
动词:getTableInfo
获取当前执行上下文中存在的表的行数和列数。
语法
getTableInfo --selector(ControlSelectors) --id(String) --name(String) --innertext(String) --tagname(String) --xpath(String) --classname(String) --elementvalue(String) --controltype(Nullable<ControlTypes>) --index(Numeric) --control(Control) [--usetable(Boolean)] [--searchbycolumn(Boolean)] --searchcolumn(String) --searchvalue(String) --returncolumn(String) --row(Numeric) [--timeout(TimeSpan)] (Numeric)=rows (Numeric)=columns
输入
| 脚本 | 设计器 | 必需的 | AcceptedTypes | 描述 |
|---|---|---|---|---|
| --selector | 选择器 | 必需的 | ControlSelectors | 用于识别用户界面控件的选择器的类型。 提供了以下选项:除了在脚本中插入带有自动填充这些参数的命令外,还可以使用 IBM RPA Studio的记录器来映射控件并获取 "选择器" 参数的必要信息。 该记录器在平台上的上方工具栏中可用。 |
| --id | 标识 | 仅当“选择器”为“标识”或“标识和名称”时 | 文本 | 用户界面控件标识。 |
| --name | 名称 | 仅当“选择器”为“名称”、“名称和值”、“标识和名称”或“类型和名称”时 | 文本 | UI 控件的名称。 |
| --innertext | 文本 | 仅当“选择器”为“内部文本和标记”时 | 文本 | UI 控件的内部文本。 |
| --tagname | 元素类型 | 仅当“选择器”为“内部文本和标记”时 | 文本 | 元素或标记的类型。元素可以是按钮、文本框及其他。 |
| --xpath | XPath | 仅当“选择器”为“XPath”时 | 文本 | UI 控件的 XPath 路径。 |
| --classname | 类 | 仅当“选择器”为“类和值”或“类名”时 | 文本 | 用户界面控件类。 |
| --elementvalue | 元素值 | 仅当“选择器”为“类和值”或“名称和值”时 | 文本 | UI 控件元素的当前值。 |
| --controltype | 类型 | 仅当“选择器”为“类型和索引”或“类型和名称”时 | ControlTypes | UI 控件类型。 选项: |
| --index | 索引 | 仅当“选择器”为“类型和索引”时 | 成员 | UI 控件的索引。 |
| --control | 控制 | 仅当“选择器”为“实例”时 | 控件 | 控件实例。使用命令搜索控件获取此变量。 |
| --usetable | 表中的元素 | 可选 | BOOLEAN | 启用后,将在表中访存元素。 |
| --searchbycolumn | 按列搜索 | 可选 | BOOLEAN | 启用后,将按列而不是行访存元素。 |
| --searchcolumn | 列 | 仅当“表中的元素”为 True 时 | 文本 | 将从中获取元素的列的名称或编号。 |
| --searchvalue | 值 | 仅当“按列搜索”为 True 时 | 文本 | 用于在表中查找元素的值。 |
| --returncolumn | 返回列 | 仅当“按列搜索”为 True 时 | 文本 | 包含控件的列。 |
| --row | 行 | 仅当“按列搜索”为 False 时 | 成员 | 从中获取元素的表行。 |
| --timeout | Timeout | 可选 | 时间范围、数字、文本 | 执行命令的最长时间。如果未在此参数中设置任何值,那么将使用设置超时命令中定义的上下文时间。 如果未使用此命令,那么缺省时间为 5 秒。 |
输出
| 脚本 | 设计器 | AcceptedTypes | 描述 |
|---|---|---|---|
| 行 | 行 | 成员 | 从表获取的行数。 |
| columns | 列 | 成员 | 从表获取的列数。 |
示例
预期会显示使用运行命令执行的 Excel 文件的窗口。 使用获取表信息命令获取行数和列数。 如果未显示此窗口,那么会发出以下消息:“Error - Window did not appear”。
defVar --name tableRowsNumber --type Numeric
defVar --name tableColumnsNumber --type Numeric
defVar --name waitWindowResult --type Boolean
defVar --name excelWindow --type Window
// Download the following file to execute the command.
// Runs the Excel file.
openFile --file "tableExcelCompanyCity.xlsx"
waitWindow --title "tableExcelCompanyCity - Excel" --classname XLMAIN --processname EXCEL excelWindow=value waitWindowResult=success
if --left "${waitWindowResult}" --operator "Is_True"
getTableInfo --selector "XPath" --xpath "/root/pane[1]/pane[1]/pane[1]/datagrid[1]\r\n" --timeout 00:00:10 tableColumnsNumber=columns tableRowsNumber=rows
logMessage --message "Number of columns the table has:${tableColumnsNumber}\r\nNumber of rows the table has:${tableRowsNumber}" --type "Info"
// Number of columns the table has: 19
// Number of rows the table has: 23
else
logMessage --message "Error - Window Did Not Appear" --type "Info"
endIf
要正确操作以上脚本,必须下载该文件并在运行命令的路径参数中输入其路径。