Get Tree Nodes

Retrieves the list of nodes of a tree view menu.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

A tree view menu, also known as a tree menu or hierarchical menu, is a graphical user interface (GUI) element that displays a hierarchical list or tree-like structure of menu items. Each item in the tree menu can have one or more child items, which can themselves have child items, creating a nested or hierarchical structure.

Retrieving the list of nodes comprising the tree view menu enables you to interact programmatically with each node of the tree.

Script syntax

IBM RPA's proprietary script 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.

getTreeNodes --path(String) [--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)] (List<String>)=value

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.

Designer mode label Script mode name Required Accepted variable types Description
Path path Required Text The path to the node from which you want to retrieve the child nodes. The path starts at the root element following the hierarchy down to the target node.
Update screen cache forcerefresh Optional Boolean Enable to refresh the screen before execution, allowing the command to identify any new elements and update the screen cache.
Selector selector Required ControlSelectors Type of selector used to identify user interface controls.

See the selector parameter options for more details.

Tip:You can use IBM RPA Studio's recorder tool to map the controls and obtain all the necessary data for this parameter.
ID id Required when selector is Id, IdAndName Text ID of the menu item from which the tree nodes are retrieved.
Name name Required when selector is Name, NameAndValue, IdAndName Text Name of the menu item from which the tree nodes are retrieved.
Text innertext Required when selector is InnerTextAndTag Text Inner text of the menu item from which the tree nodes are retrieved.
Control Name tagname Required when selector is InnerTextAndTag Text Name of the menu item from which the tree nodes are retrieved.
XPath xpath Required when selector is Xpath Text XPath that leads to the control from which the tree nodes are retrieved.
Class classname Required when selector is ClassandValue, ClassName Text Class of the menu item from which the tree nodes are obtained.
Control Value elementvalue Required when selector is ClassandValue, NameAndValue Text Value of the menu item from which the tree nodes are retrieved.
Type controltype Required when selector is TypeandIndex, TypeandName ControlTypes Type of control from which the tree nodes are retrieved.

See the controltype parameter options for more details.
Index index Required when selector is typeandindex Number Control index from which the tree nodes are retrieved.
Control control Required when selector is control Control Control instance.

✪ Tip: Use the Search Control (searchcontrol) command to obtain the control instance.
Element in Table usetable Optional Boolean Enable to find an element within a table searching by column or row.
Search by Column searchbycolumn Optional Boolean Enable to search for the element in the table by column instead of rows.
Column searchcolumn Required when usetable is true Text Name or value of the table column which contains the element.
Value searchvalue Required when the searchbycolumn is true Text Value used to find the element in the table.
Return Column returncolumn Required when searchbycolumn is true Text Column that contains the element.
Row row Required when searchbycolumn is false Number Table row to find the element.
Timeout timeout Optional Time Span, Number, Text Command execution timeout.

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 It matches the control's unique identifier.
Name Name It matches the control name.
Name and value NameAndValue It matches the control name and the value.
XPath XPath It matches the XPath of the root element from the tree menu that you want to retrieve nodes.
ID and name IdAndName It matches the unique identifier and the control name.
Class and value ClassandValue It matches the control class name and the value.
Class Name ClassName It matches the class name that instantiates the control.
Inner text and control type InnerTextAndTag It matches the control inner text and its type attributes.
Instance instance It matches the control instance.
Vision vision It matches the mapped image that identifies the control.
Type and index typeandindex It matches the control type and the index of its position among controls of equal type.
Type and name TypeandName It matches the control type and the name.

controltype parameter options

The following table displays the options available for the ControlTypes 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
Button Button It matches the Button control in the application.
Check box CheckBox It matches the Check box control in the application.
Child window ChildWindow It matches the Child window control in the application.
Combo box ComboBox It matches the Combo box control in the application.
Generic Generic It matches the Generic control in the application.
Image Image It matches the Image control in the application.
Label Label It matches the Label control in the application.
List box ListBox It matches the List box control in the application.
Menu bar MenuBar It matches the Menu bar control in the application.
Menu item MenuItem It matches the Menu item control in the application.
Progress bar ProgressBar It matches the Progress bar control in the application.
Radio button RadioButton It matches the Radio button control in the application.
Scroll bar ScrollBar It matches the Scroll bar control in the application.
Slider Slider It matches the Slider control in the application.
Spinner Spinner It matches the Spinner control in the application.
Status bar StatusBar It matches the Status bar control in the application.
Tab page TabPage It matches the Tab page control in the application.
Tab panel TabPanel It matches the Tab panel control in the application.
Table Table It matches the Table control in the application.
Text box TextBox It matches the Text box control in the application.
Toggle button ToggleButton It matches the Toggle button control in the application.
Tree view TreeView It matches the Tree view control in the application.
TreeTable TreeTable It matches the TreeTable control in the application.
Window Window It matches the Window control in the application.

Output parameters

Designer mode label Script mode name Accepted variable types Description
Nodes value List<String> Returns the nodes of the defined element of the tree.

Example

The following code example demonstrates how to obtain the nodes of the inbox tree view menu of the Outlook desktop application.

defVar --name outlookWindow --type Window
defVar --name treeNodes --type List --innertype String
launchWindow --executablepath "C:\\\\Program Files\\\\Microsoft Office\\\\root\\\\Office16\\\\OUTLOOK.EXE" --safesearch  outlookWindow=value
getTreeNodes --path "User.user@hotmail.com\r\nInbox" --forcerefresh  --selector "XPath" --xpath "/root/pane[5]/pane[1]/custom[1]/pane[1]/tree[1]" --timeout "00:00:05" --comment "Gets the nodes of the \"Inbox\" element searching by the XPath of the root element." treeNodes=value
logMessage --message "${treeNodes}" --type "Info" --comment "Logs the nodes inside the \"Inbox\" element."