Get Parent from Element - Activities - Foundation 23.2 - Foundation 23.2 - Ready - Hyland RPA - external

Hyland RPA Activities

Platform
Hyland RPA
Product
Activities
Release
Foundation 23.2
License

Automation.Getter

Description

Returns the parent of a given element. Examples on a web page include retrieving the div element that contains a table or extracting the text from the grandparent of your current element.

Properties

Analyst

  • Description: Optional text for documentation purposes.

Common

  • Continue On Error: Continues the execution of the workflow even if an error occurs during the execution of the activity.

  • Delay Before: Delay time in milliseconds before the activity is executed. The default value is 250 milliseconds.

  • Delay After: Delay time in milliseconds after executing of the activity. The default value is 250 milliseconds.

  • Disable Log: Disables the logging functionality for this activity.

  • Disable Protocol: Disables the protocol functionality for this activity.

  • Exclude from Global Delay: Excludes this activity from the Global Delay functionality.

  • Timeout: Duration in milliseconds in which the activity tries to execute.

Element

  • Automation Provider: The automation provider is usually automatically selected by the Smart Indicator depending on the application or browser you are automating. You can, however, change the automation provider manually while indicating (by pressing Shift + Up/Down)
  • ArtefactID: If you have saved the selector value in an Artifact, you can reference it here. If the value is 0, it is not connected to any Artifact in the database.
  • Element: In case you already retrieved the UIElement in the process, you can simply insert it in this field.
  • Selector Value: This is the field where the Smart Indicator will store your indication result. You can, of course, also adjust the selector value manually.
  • Show Debug Borders: If true draws a bounding rectangle around the element identified to be the target.

Output

  • Parent: The activity will return a UIElement (the parent of the element you set under Element). If your element does not have a parent, an ElementNotFoundException will be thrown.

Example

Suppose you are on our helpdesk site and that you currently have an array of all links (class="sidnav__article-name") leading to the relevant article.

Starting with this array, you want to retrieve the text of the headline corresponding to each link (i.e., Account Management => CUSTOMER PORTAL, Update Your Applications => CUSTOMER PORTAL, Compatibility Matrix => RELEASE HISTORY and so on). In order to get the displayed text of the span element, you will have to use the Get Parent from Element Activity twice (or chain the GetParent()-method as described in the tips and tricks section) as shown in the following screenshots from within the For Each UI Element Activity:

Second, you need to retrieve your final target element (the span element), namely the first sibling of this grandparent of your initial link element (parentOfLinkElement). The Get Siblings from Element will again return an array of UIElements (here: siblingsOfLIElement).

Finally, you can use the Get Text Activity to extract the text from the headline (access the first sibling like this: siblingsOfLIElement(0)) as well as the text from your initial link element. Their content is written to the log using the Write Log activity:

This example will help you to become comfortable with the Get Parent from Element and Get Siblings from Element activities. Here is an excerpt from the web page (relevant parts are highlighted):

<li class="sidenav__section " data-sidenav-section-id="360000499998">
    <span class="sidenav__section-name">Customer Portal</span>
    <ul class="sidenav__articles-list " style="transition: transform 300ms" data-sidenav-parent-section="360000499998">
        <li class="sidenav__article " data-sidenav-article-id="360001838498">
            <a href="https://helpdesk.anothermonday.com/hc/en-us/articles/360001838498-Account-Management" class="sidenav__article-name">Account Management</a>
        </li>
        <li class="sidenav__article " data-sidenav-article-id="360001839218">
            <a href="https://helpdesk.anothermonday.com/hc/en-us/articles/360001839218-Install-and-Activate-your-Applications" class="sidenav__article-name">Install and Activate your Applications</a>
        </li>
        ...    
    </ul>
</li>

<li class="sidenav__section " data-sidenav-section-id="360000367717">
    <span class="sidenav__section-name">Release History</span>
    <ul class="sidenav__articles-list " style="transition: transform 300ms" data-sidenav-parent-section="360000367717"> 
        <li class="sidenav__article " data-sidenav-article-id="360002037177">
            <a href="https://helpdesk.anothermonday.com/hc/en-us/articles/360002037177-Compatibility-Matrix" class="sidenav__article-name">Compatibility Matrix</a>
        </li>
        ...

Tips and Tricks

  • If you want to get grand- or grand-grandparents, you can chain the Get Parent from Element Activity or use Visual Basic commands instead, for example, you could use Assign Variable with variable type UiElement and myElement.GetParent().GetParent().GetSiblings()(0) on the right hand sight of the assignment if you want to retrieve the span element mentioned in the exercise above starting from the link element.

Troubleshooting

  • AM.Core.Activities.Exceptions.ElementNotFoundException: Failed
    to find Element by the given selector.
    The activity could not find an element based on the selector value or element you provided as target. Check if your selector value is correct. The same exception is thrown if your element has no parent (for example, the HTML element of a web page).

See also