Get Amount of Combo Box Options
Get the number of options in a combination box on the web page.
Command availability: IBM RPA SaaS and IBM RPA on premises
Script syntax
IBM RPA's proprietary scripting language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.
webGetComboBox --selector(WebComboBoxElementSelectors) --id(String) --name(String) --css(String) --innertext(String) --tagname(String) --xpath(String) [--simulatehuman(Boolean)] [--timeout(TimeSpan)] (Numeric)=value
Dependencies
- Use the Start Browser (
webStart) command to start a browser or use the Find Internet Explorer Browser (findBrowser) command to attach the Microsoft Internet Explorer before using the Get Amount of Combo Box Options (webGetComboBox) command.
Input parameter
The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.
| Designer mode label | Script mode name | Required | Accepted variable types | Description |
|---|---|---|---|---|
| Search by | selector |
Required |
WebComboBoxElementSelectors |
Type of selector to identify the combination box in the web page. See the selector parameter options. |
| ID | id |
Required when the Search by parameter is Id, IdAndName |
Text |
A text that contains the ID attribute value to match the combination box. |
| Name | name |
Required when the Search by parameter is Name, IdAndName |
Text |
A text that contains the Name attribute value to match the combination box. |
| Element CSS | css |
Required when the Search by parameter is CssSelector |
Text |
A text that contains the CSS selector to match the combination box. |
| Element text | innertext |
Required when the Search by parameter is InnerTextAndTag |
Text |
A text that contains the element text content to match the combination box. |
| Element Tag name | tagname |
Required when the Search by parameter is InnerTextAndTag |
Text |
A text that contains the tag name attribute value to match the combination box. |
| Element XPath | xpath |
Required when the Search by parameter is XPath |
Text |
A text that contains the XML path value to match the combination box. |
| Simulate human | simulatehuman |
Optional |
Boolean |
This parameter does not change the behavior of the command. |
| Timeout | timeout |
Optional |
Time Span, Number, Text |
Maximum waiting time for running the command. When blank, the default timeout is 5 seconds. |
selector parameter options
The following table displays the options available for the selector input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.
| Designer mode label | Script mode name | Description |
|---|---|---|
| Id | Id |
Matches the element based on the ID attribute value. |
| Name | Name |
Matches the element based on the Name attribute value. |
| Css | CssSelector |
Matches the element based on the CSS selector value. |
| Inner text and control type | InnerTextAndTag |
Matches the element based on the element text content and the tag name attribute value. |
| XPath | XPath |
Matches the element based on the XML path in the HTML root. |
| Id and name | IdAndName |
Matches the element based on the id and name attribute value. |
Output parameter
| Designer mode label | Script mode name | Accepted variable types | Description |
|---|---|---|---|
| Options | value |
Number |
Return a Number value that contains the number of options in the combination box. |
Example
The following code example demonstrates how to get the number of options in the combination box on the web page. The Get Amount of Combo Box Options (webGetComboBox) command uses the id selector of
the combination box to get these values.
defVar --name numberOfOptions --type Numeric
defVar --name webpage --type String --value "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select"
// Launches the Google Chrome browser
webStart --name browser --type "Chrome"
// Navigates to the web page with the combination box
webNavigate --url "${webpage}"
webGetComboBox --selector "Id" --id cars --simulatehuman numberOfOptions=value
// Logs the number of the options in the combination box
logMessage --message "The number of options: ${numberOfOptions}" --type "Info"
webClose --name browser
Limitations
- When interacting with a nonunique web element, using XPath or CSS selectors that is inside an IFrame, you must specify the element inside the IFrame for the command to interact with. Otherwise, only the first element is found.
- This command supports only combination boxes defined by the HTML tag
<select>.