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 parameters | Input parameter type | Description |
|---|---|---|
| Webpage Object | WebPage | Webpage containing the source element |
| Web Element | WebElement 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 |
| 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 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 |
|---|---|---|
| Web Element | WebElement 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
- 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_elementtool.
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
- Get the product-list element.
- Get its direct children, where each child represents one product.
- 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.