Skip to main content

Get Related Web Elements

Command description

Get the parent, children, siblings, or a descendant of a specified web element. An element has one parent but may have multiple children or siblings. If multiple descendants match, refine the captured descriptor so that it identifies one element. Select Descendant Element and specify an index to retrieve the nth matching descendant of the target element.

Command Input Parameters

input parametersInput parameter typeDescription
Webpage ObjectWebPageWebpage containing the source element
Web ElementWebElement or str (captured element UID, not element name, not ms-rpa-id)Select a captured element or one returned by Get Web Element, Get Similar Web Elements, or Get Related Web 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 DurationnumberMaximum 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
Web ElementWebElement or list[WebElement]WebElement for Parent Element, Previous Sibling Element, Next Sibling Element, or Descendant Element; list[WebElement] for Child Element or Sibling Element

Type definition reference

tip
  • Install the Runavelo browser extension before using this command.
  • See Capture Web Elements .
  • If a descendant descriptor has not been captured, the AI can call the start_capture_descendant_web_element tool.

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 Taobao product names and prices.

The product list (.tbpc-row) contains multiple product elements (.tbpc-col). Each product contains a name element (A SPAN.info-wrapper-title-text) and a price element (A DIV.price-wrapper).

Process

  1. Get the product-list element.
  2. Get its direct children, where each child represents one product.
  3. Get the matching descendants of each product.
  • Product list elements

  • Descendant elements (product price elements)

    Because the search starts at single product element, do not include that element or its ancestors in the descendant descriptor. Runavelo searches with singleProductElement.querySelectorAll(selectedTag1 selectedTag2...), so select only the descendant tags needed to identify the target.

FAQ

See Web Automation FAQ