选择组合框中的项
选择组合框中的项目。
命令可用性: 本地 IBM RPA SaaS 和 IBM RPA
Description
使用选择器类型来选择 Web 应用程序的组合框中的项,以进行标识。
脚本语法
IBM RPA 的专有脚本语言具有类似于其他编程语言的语法。 该脚本语法在脚本文件中定义命令的语法。 您可以在 IBM RPA Studio的 脚本 方式下使用此语法。
webSetComboBox --selectoptionby(SetComboBoxTypes) --value(String) --matchbytext(String) --index(Numeric) [--nowait(Boolean)] --selector(WebComboBoxElementSelectors) --id(String) --name(String) --css(String) --innertext(String) --tagname(String) --xpath(String) [--simulatehuman(Boolean)] [--timeout(TimeSpan)] (Boolean)=value
依赖关系
在使用选择组合框中的项 (webSetComboBox) 命令之前,请使用启动浏览器 (webStart) 命令来启动浏览器或使用查找 Internet Explorer 浏览器 (findBrowser) 命令来连接 Microsoft Internet Explorer。
输入参数
下表显示了此命令中提供的输入参数的列表。 在表中,您可以看到在 IBM RPA Studio的脚本方式及其 Designer 方式等效标签中工作时的参数名称。
| 设计器方式标签 | 脚本方式名称 | 必需的 | 接受的变量类型 | Description |
|---|---|---|---|---|
| 选项选择依据 | selectoptionby |
Required |
SetComboBoxTypes |
选择搜索选项的类型。 请参阅 selectoptionby 参数选项。 |
| 要选择的值 | value |
Required when the Select Option by is Value |
Text |
选择的项的值。 |
| 要比较的文本 | matchbytext |
Required when the Select Option by is matchByText |
Text |
组合框中显示的文本。 |
| 索引 | index |
Required when the Select Option by is Index |
Number |
组合框中的项的索引。 索引从 1 开始。 |
| 不等待 | nowait |
Optional |
Boolean |
启用以忽略超时。 |
| 搜索依据 | selector |
Required |
WebFieldElementSelectors |
用于标识 Web 页面中的 Web 元素的选择器类型。 请参阅 selector 参数选项。 |
| 标识 | id |
Required when the Selector type parameter is Id, IdAndName |
Text |
包含标识属性值的文本,以匹配并选择组合框。 |
| 元素名称 | name |
Required when the Selector type parameter is Name, IdAndName |
Text |
包含名称属性值的文本,以匹配并选择组合框。 |
| 元素 CSS | css |
Required when the Selector type parameter is CssSelector |
Text |
包含 CSS 选择器的文本,以匹配并选择组合框。 |
| 元素中的文本 | innertext |
Required when Search by is InnerTextAndTag |
Text |
在组合框内找到的文本。 |
| 标记名称 | tagname |
Required when Search by is InnerTextAndTag |
Text |
该组合框的 HTML 标记的名称。 |
| 元素 XPath | xpath |
Required when the Selector type parameter is XPath |
Text |
包含 XML 路径值的文本,以匹配并选择组合框。 |
| 模拟人类 | simulatehuman |
Optional |
Boolean |
移动鼠标光标并选择用户选择的选项。 |
| Timeout | timeout |
Optional |
Time Span, Number, Text |
运行命令时的最长等待时间。 如果为空白,那么缺省超时为 5 秒。 |
selectoptionby 参数选项
下表显示了可用于 selectoptionby 输入参数的选项。 该表显示了在脚本方式下工作时的可用选项以及在设计器方式下的等效标签。
| 设计器方式标签 | 脚本方式名称 | Description |
|---|---|---|
| 索引 | index |
组合框中的项的索引。 |
| 与文本匹配 | matchbytext |
要与项值进行比较的文本。 |
| 值 | value |
项值。 |
selector 参数选项
下表显示了可用于 Search by 输入参数的选项。 该表显示了在脚本方式下工作时的可用选项以及在设计器方式下的等效标签。
| 设计器方式标签 | 脚本方式名称 | Description |
|---|---|---|
| Css | CssSelector |
根据 CSS 选择器值匹配 Web 元素。 |
| 标识 | Id |
根据标识属性值匹配 Web 元素。 |
| 标识和名称 | IdAndName |
根据标识和名称属性值匹配 Web 元素。 |
| 内部文本和控件类型 | InnerTextAndTag |
根据元素文本内容和标记名称属性值与 Web 元素相匹配。 |
| 名称 | Name |
根据“名称”属性值匹配 Web 元素。 |
| XPath | XPath |
根据 HTML 根中的 XML 路径匹配 Web 元素。 |
输出参数
| 设计器方式标签 | 脚本方式名称 | 接受的变量类型 | Description |
|---|---|---|---|
| 成功 | value |
Boolean |
如果值已成功分配给字段,那么返回 true;如果未分配,那么返回 false。 |
示例
在 ANVISA Web 站点上的组合框中选择 Hortolândia 市。
webStart --name browser --type "Chrome"
webNavigate --url "https://www.anvisa.gov.br/datavisa/SelecionaCidade.asp?sArgumento=SP"
// The command uses the element CSS to find the combo box and select the HORTOLÂNDIA value comparing the text which value entered in the Text to Compare parameter.
webSetComboBox --selectoptionby "MatchByText" --matchbytext HORTOLÂNDIA --selector "CssSelector" --css "body > form > table > tbody > tr:nth-child(4) > td > select" --simulatehuman
webClose --name browser --leavebrowseropen
// Keep the browser open.
限制
- 当使用 XPath 或 CSS 选择器与不唯一的 Web 元素进行交互时,即在 IFrame 内,需要指定命令将与 IFrame 内的哪个元素进行交互。 否则,将仅查找第一个元素。
- 在
Text to Compare参数中,请不要使用引用 HTMLvalue标记内容的值。 - 此命令仅支持使用 HTML 标记
<select>定义的组合框。