Get Related Desktop Elements
Command description
Get the parent, child, sibling, or descendant of the specified desktop element. An element has at most one parent, but it may have multiple children or siblings. If multiple descendants match, the command reports an error; refine the captured element so that it always identifies a unique target. Select Descendant Element and specify an index to retrieve the nth matching descendant of the target element.
Command Input Parameters
| input parameters | Input parameter type | Description |
|---|---|---|
| Desktop Element | WinElement or str (captured element UID, not element name, not ms-rpa-id) | Source element. Select a captured element or use Get Desktop Element, Get Similar Desktop Elements, or Get Related Desktop Elements |
| Relationship | enum | Parent Element, Child Element, Sibling Element, Descendant Element |
| Descendant Elements | str | UID of the captured descendant descriptor, not its name or ms-rpa-id. Required only when Relationship is Descendant Element; the search starts from Desktop Element |
| Element Wait Duration | number | Maximum time to wait for the related element, in seconds. On timeout, the command reports an error or returns an empty list, depending on the relationship |
Command Output Parameters
| Output parameters | Output parameter type | Description |
|---|---|---|
| Desktop Element | WinElement or list[WinElement] | WinElement for Parent Element or Descendant Element; list[WinElement] for Child Element or Sibling Element |
Type definition reference
tip
- Capture element reference Capture Desktop Elements
Applicable scenarios
- Locate a target relative to an element that is easier to identify.
- For example, after locating a product name in a list, retrieve the related price element.
Example
Get the group name in WeChat chat history
WeChat chat history is a list containing multiple direct child items. Each item represents a group or contact and contains its name.
Process
- Get the list element.
- Get all direct
Itemchildren of the list. - Get the matching descendant of each item.
-
list elements
-
Descendants elements
Because the search starts at
Item, do not includeListItemControlor any ancestor nodes in the descendant descriptor.