Get Options

Gets the options of a user interface control.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Gets the options of a user interface control. Controls are, in the context of Windows, elements that allow the user to interact with an application. Controls can be buttons, data entry fields, menus, and various other elements. The expected result is a data table or a string dictionary with the desired value.

Script Syntax

getOptions [--forcerefresh(Boolean)] --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)] (DataTable)=properties (StringDictionary<String>)=valueText (StringDictionary<String>)=indexText

Input parameters

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.

Label in Designer mode Script mode name Required Accepted variable types Description
Update screen cache forcerefresh Optional Boolean When enabled, screen cache is updated before running the command to identify new elements. This identification is necessary for the command to work in case there are any changes on the screen.
Selector selector Required ControlSelectors Types of selectors used to identify user interface controls.

See the selector parameter options.

Notes: You can use the IBM RPA Studio's recorder to map the controls to obtain the necessary information for the Selector parameters. You can also use it to add commands to the script. See the Recorder documentation for more information.
Id id Only when Selector is Id, IdAndName Text Id of the control from which the options should be obtained.
Name name Only when Selector is Name, NameAndValue, IdAndName, TypeAndName Text Name of the control from which the options should be obtained.
Text innerText Only when Selector is InnerTextAndTag Text Internal text of the control.
ElementType tagname Only when Selector is InnerTextAndTag Text Type, or tag, of the element from which to get options.

Notes: An element can be a button or a text box.
XPath xpath Only when Selector is XPath Text XPath path leading to the control from which the options should be obtained.
Class classname Only when Selector is ClassAndValue, ClassName Text Class of the control from which the options should be obtained.
ElementValue elementvalue Only when Selector is ClassAndValue, NameAndValue Text Current value of the element from which the options should be obtained.
Type controltype Only when Selector is TypeAndIndex, TypeAndName ControlTypes Types of controls available for the selector to find.

See the controltype parameter options.
Index index Only when Selector is TypeAndIndex Number Index of the control from which the options should be obtained.
Control control Only when Selector is Instance Control Control instance. You can obtain this variable using the Search Control command.
Element in Table usetable Optional Boolean When enabled, searches for the element within a table, by column or row.
Search by Column searchbycolumn Optional Boolean When enabled, fetches the element in the table by column rather than row.
Column searchcolumn Only when Element in Table is True Text Name or value of the column.
Value searchvalue Only when Search by Column is True Text Value used to find the element in the table.
Return Column returncolumn Only when Search by Column is True Text Column that contains the control.
Row row Only when Search by Column is False Number Table row to find the element.
Timeout timeout Optional Time Span, Number, Text Command execution timeout.

Notes: The default timeout is 5 seconds. You can change the default value by using Set Timeout (setTimeout) command.

selector parameter options

The following table displays the options available for the Selector input parameter.

Designer mode label Script mode name Description
Class and value ClassAndValue The selector that identifies a user interface by Class and Value.
Class name ClassName The selector that identifies a user interface by Class name.
Id Id The selector that identifies a user interface by Id.
Id and name IdAndName The selector that identifies a user interface by Id and Name.
Inner text and control type InnerTextAndTag The selector that identifies a user interface by Inner text and control type.
Instance Instance The selector that identifies a user interface by Instance.
Name Name The selector that identifies a user interface by Name.
Name and value NameAndValue The selector that identifies a user interface by Name and value.
Type and index TypeAndIndex The selector that identifies a user interface by Type and index.
Type and name TypeAndName The selector that identifies a user interface by Type and name.
XPath XPath The selector that identifies a user interface by XPath.

controltype parameter options

The following table displays the options available for the controltype input parameter.

Designer mode label Script mode name Description
Button Button The control type is a Button.
Check box CheckBox The control type is a Check box.
Child window ChildWindow The control type is a Child window.
Combo box ComboBox The control type is a combination box.
Generic Generic The control type is a Generic.
Image Image The control type is an Image.
Label Label The control type is a Label.
List box ListBox The control type is a List box.
Menu bar MenuBar The control type is a Menu bar.
Menu item MenuItem The control type is a Menu item.
Progress bar ProgressBar The control type is a Progress bar.
Radio button RadioButton The control type is a Radio button.
Scroll bar ScrollBar The control type is a Scroll bar.
Slider Slider The control type is a Slider.
Spinner Spinner The control type is a Spinner.
Status bar Status bar The control type is a Status bar.
Tab page TabPage The control type is a Tab page.
Tab panel TabPanel The control type is a Tab panel.
Table Table The control type is a Table.
Text box TextBox The control type is a Text box.
Toggle button ToggleButton The control type is a Toggle button.
Tree view TreeView The control type is a Tree view.
TreeTable TreeTable The control type is a TreeTable.
Window Window The control type is a Window.

Output parameter

Designer mode label Script mode name Accepted variable types Description
Properties properties Data Table Returns a data table with index, value, and text for each option.
Value-Text Dictionary valueText String Dictionary<Text> Returns a string dictionary, entering the key and value of each option.
Index-Text Dictionary indexText String Dictionary<Text> Returns a string dictionary with the indexes associated with the text of each option.

Example

Based on the executable opened by the Launch and Attach Window command, the command gets the options from the combination box "Country", identifying it through the ID assigned to it and mapped by the IBM RPA Studio's recorder.

defVar --name dataTableResult --type DataTable
defVar --name indexTextResult --type "StringDictionary<TValue>" --innertype String
// Opens an app for testing.
launchWindow --executablepath "CSharpTestApp.exe"
// Get the options of the entered control.
getOptions --selector "IdAndName" --id cmbCountry --name "Country :" dataTableResult=properties indexTextResult=indexText
logMessage --message "Data Table: ${dataTableResult}\r\nIndex and Value: ${indexTextResult}" --type "Info"
// Returns data table with index, key and value for each option and a dictionary with indexes associated with each option text.