Get Related Mobile Elements
Command description
Get the parent, child, sibling, or descendant of the specified mobile 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 |
|---|---|---|
| Mobile Device Object | Phone | Connected mobile-device object |
| Mobile Element | PhoneElement or str (captured element UID, not element name, not ms-rpa-id) | Select a captured mobile element or an element returned by Get Mobile Element, Get Similar Mobile Elements, or Get Related Mobile Elements |
| Relationship | enum | Parent Element, Child Element, Sibling Element, Previous Sibling Element, Next Sibling Element, Descendant Element |
| Descendant Elements | str | UID of the captured descendant element, not its name or ms-rpa-id; required only when Relationship is Descendant Element |
| Element Wait Timeout | 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 |
|---|---|---|
| Mobile Element | PhoneElement or list[PhoneElement] | PhoneElement for Parent Element, Previous Sibling Element, Next Sibling Element, and Descendant Element; otherwise list[PhoneElement] |
Type definition reference
Relationship descriptions
| Relationship | Description |
|---|---|
| Parent Element | Get the direct parent node and return one element |
| Child Element | Get the direct children, usually returning multiple elements |
| Sibling Element | Get other elements at the same level, usually returning multiple elements |
| Descendant Element | Find a matching descendant inside the current element, such as a field in a product card or contact item |
Related links
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.
tip
Enable Developer options on the mobile device, then connect it to the computer with a USB cable. See Connect Mobile Device