Definition and Usage
This command retrieves a specific related element (parent, sibling, or descendant) of a given element on a web page. It allows you to navigate the DOM structure to locate elements based on their relationship to a reference element.
Parameter Values
Input parameters
Parameter | Description | Possible Values | Required | Options / Notes |
Web page | Select a variable that contains the web page to work with | Any web page variable | Yes | Must be a previously opened web page |
Element | Select or capture an element to operate on | Any web element | Yes | Use the Capture button to select an element directly from the page |
Relationship | Specify how the element is related | Parent element, Previous sibling element, Following sibling element, First descendant element, All child elements, Specific child element | Yes | Determines the type of relative element to retrieve |
Relative XPath | Relative xpath of the child element relative to the selected element | Valid XPath expression | Conditional | Required only when "Specific child element" is selected |
Index of child | Index of child in the parent element | Numeric value | Conditional | Required only when "All child elements" is selected and you need a specific child |
Save element as | Store the element in a new variable | Valid variable name | Yes | The variable name to store the retrieved element |
Advanced settings
Parameter | Description | Possible Values | Required | Options / Notes |
Element timeout (s) | Wait time for element to appear (seconds) | Numeric value | No | Default is 20 seconds; increase for slow-loading pages |
Error handling
Parameter Name | Description |
Throw error & stop | When an error occurs, the action will trigger an error and stop the execution of the entire app. |
Retry command | If an error occurs, the action will retry the command in an attempt to resolve the issue and continue the process. |
Ignore error & continue | When an error occurs, the action will be ignored, and the workflow will continue without interruption. |
Variables produced
This action produces a variable that contains the retrieved relative element. The variable can be used in subsequent actions to interact with the element.
Using Variables in Conditions
You can use the {x} syntax to insert variables into parameter fields. This is particularly useful when you need to dynamically select web pages or elements based on previous operations. When using variables, ensure that the variable type matches the expected parameter type (e.g., a web element variable for the Element parameter).
Notes
Before using this command, ensure that the web page is properly loaded and the reference element exists.
The relationship option determines how the DOM is traversed to find the relative element:
Parent element: Gets the direct parent of the selected element.
Sibling elements: Gets elements at the same level in the DOM hierarchy.
Descendant elements: Gets elements contained within the selected element.
If the specified relative element cannot be found within the timeout period, the command will fail.
When working with dynamic web pages, consider increasing the element timeout value to allow sufficient time for elements to load.