Skip to main content

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 parametersInput parameter typeDescription
Mobile Device ObjectPhoneConnected mobile-device object
Mobile ElementPhoneElement 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
RelationshipenumParent Element, Child Element, Sibling Element, Previous Sibling Element, Next Sibling Element, Descendant Element
Descendant ElementsstrUID of the captured descendant element, not its name or ms-rpa-id; required only when Relationship is Descendant Element
Element Wait TimeoutnumberMaximum 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 parametersOutput parameter typeDescription
Mobile ElementPhoneElement or list[PhoneElement]PhoneElement for Parent Element, Previous Sibling Element, Next Sibling Element, and Descendant Element; otherwise list[PhoneElement]

Type definition reference

Relationship descriptions

RelationshipDescription
Parent ElementGet the direct parent node and return one element
Child ElementGet the direct children, usually returning multiple elements
Sibling ElementGet other elements at the same level, usually returning multiple elements
Descendant ElementFind a matching descendant inside the current element, such as a field in a product card or contact item

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

FAQ

See Mobile Automation FAQ