Select Item in Combo Box

Selects an item in a combination box.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Selects an item in a combination box of a web application using a selector type to identify it.

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.

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

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 Select Item in Combo Box (webSetComboBox) 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
Select Option by selectoptionby Required SetComboBoxTypes Select the type of search option.

See the selectoptionby parameter options.
Value to Select value Required when the Select Option by is Value Text Value of the item that is selected.
Text to Compare matchbytext Required when the Select Option by is matchByText Text The text shown in the combination box.
Index index Required when the Select Option by is Index Number Index of the item in the combination box. Index starts at 1.
No wait nowait Optional Boolean Enable to ignore the timeout.
Search by selector Required WebFieldElementSelectors Type of selector to identify the web elements in the web page.

See the selector parameter options.
Id id Required when the Selector type parameter is Id, IdAndName Text A text that contains the ID attribute value to match and select the combination box.
Element name name Required when the Selector type parameter is Name, IdAndName Text A text that contains the Name attribute value to match and select the combination box.
Element CSS css Required when the Selector type parameter is CssSelector Text A text that contains the CSS selector to match and select the combination box.
Text in Element innertext Required when Search by is InnerTextAndTag Text Text found inside the combination box.
Tag Name tagname Required when Search by is InnerTextAndTag Text Name of the HTML tag of the combination box.
Element Xpath xpath Required when the Selector type parameter is XPath Text A text that contains the XML path value to match and select the combination box.
Simulate human simulatehuman Optional Boolean Moves the mouse cursor and selects the options chosen by the user.
Timeout timeout Optional Time Span, Number, Text Maximum waiting time for running the command. When blank, the default timeout is 5 seconds.

selectoptionby parameter options

The following table displays the options available for the selectoptionby 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
Index index Index of the item in the combination box.
Match to Text matchbytext Text to be compared to the item value.
Value value Item value.

selector parameter options

The following table displays the options available for the Search by 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
Css CssSelector Matches the web element based on the CSS selector value.
Id Id Matches the web element based on the ID attribute value.
Id and name IdAndName Matches the web element based on the id and name attribute value.
Inner text and control type InnerTextAndTag Matches the web element based on the element text content and the tag name attribute value.
Name Name Matches the web element based on the Name attribute value.
XPath XPath Matches the web element based on the XML path in the HTML root.

Output parameter

Designer mode label Script mode name Accepted variable types Description
Success value Boolean Returns true if the value assigns successfully to the field, or false if not.

Example

Select the city of Hortolândia in the combination box on the ANVISA website.

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.

Limitations

  • When interacting with a not unique web element, using XPath or CSS selectors, that is inside an IFrame, it is necessary to specify which element inside the IFrame the command will interact with. Otherwise, only the first element will be found.
  • In the Text to Compare parameter don't use the value that refers to the HTML value tag content.
  • This command supports only defined combination box using the HTML tag <select>.