Get related elements Version 2 (Net)

Action group: Windows  Subgroup "Interaction with Win-elements"


Description

The action checks the specified element and returns elements related to it (parent/child/neighboring).

Example in Notepad:

"Status bar" is the neighboring element to "Scale". Parent element - "View". Daughter elements: "Zoom in", "Zoom out", "Set scale by default".

Action icon

Settings of parameters

ParameterDescription
ElementParameter that stores the data of the Win-element whose coordinates will be checked.
Type of connection

Drop-down list with elements: "Parent elements", "Daughter elements", "Neighboring elements".

If "Parent element" is selected, the result will be a collection with Win-elements that are the parents of the specified element.

If "Daughter elements" is selected, the result will be a collection with Win-elements that are daughters to the specified element.

If "Neighboring elements" is selected, the result will be a collection with Win-elements that are "neighbors" for the specified element, I.e. they have a common parent.

Search depth

Nesting level of related elements to which the search will be performed. A positive integer from 1 to infinity.

Default value is "1". The depth is not taken into account if the value "Neighboring elements" is selected in the "Type of connection" field. 

If the depth specified in the parameter is greater than the actual depth in the application, then all elements up to the actual depth are taken.

Time-out, msTime in milliseconds for which the desired element will be searched.
Window order

Sequence number of the window that the action should work with if there are multiple windows.

In this case, the action searches only for those windows in which the element should be located according to its parameters.

A positive integer from 1. The default is "1".

Output parameters

Result - a collection of Win-elements.

Settings

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
ElementA resource that stores data about the selected application element.Robin.WinElement
Yes
Type of connectionThe type of relationship between the elements being searched for and the specified element. You can search for elements that are parent, child, or neighbor to the specified element. Neighbors share a common parent element with the searched element.Robin.String
Yes
Search depthThe nesting level of related elements to which the search will be performed. If the specified depth is greater than the actual depth, the action will return all elements up to the actual depth. The default value is 1. The parameter is ignored if the "Neighboring items" value is selected in the "Type of connection" field.Robin.Numeric
No
Time-out, msThe time in milliseconds for which the desired element will be searched.Robin.Numeric
No
Window orderThe sequence number of the window that the action should work with. If you do not specify a window number, the first window will be checked. The numbering starts from 1.Robin.Numeric
No
Results
ResultA collection with related elements.Robin.Collection

Special conditions of use

If the user selects "Parent elements" in the "Type of connection" field and the specified Win-element does not have a parent, an empty collection will be returned as a result.

If the user selects "Neighboring elements" in the "Type of connection" field and the specified Win-element does not have neighbors, an empty collection will be returned as a result.

If the user selects "Daughter elements" in the "Type of connection" field and the specified Win-element does not have daughters, an empty collection will be returned as a result.

The graph traversal method is in width.

Example of action performance 

  • The user specified element L, "Search depth"=3, "Type of connection" = "Parent elements". The result is a collection with elements E, B, A.
  • The user specified element B, "Search depth"=2, "Type of connection" = "Daughter elements". The result is a collection with elements D, E, I, J, K, L.
  • The user specified element F, "Type of connection" = "Neighboring elements". The result is a collection with elements G,H. 
  • The user specified element A, "Type of connection" = "Parent elements". The result is an empty collection. 
  • The user specified element A, "Type of connection" = "Neighboring elements". The result is an empty collection. 
  • The user specified element I, "Type of connection" = "Daughter elements". The result is an empty collection.

Example of use

Task

A Notepad is opened. Get related elements of the "Scale" element. 

Solution

Use the "Get related elements" action.

Implementation

  1.  Assemble a robot scheme with the actions:

  2. Set the "Run" action parameters.

  3. Set the "Window focus element" action parameter. The element must be obtained using the WinSpy tool. Working with WinSpy is described in the section Getting a Win-element. Setting a timeout, in general, does not lead to an increase in the execution time of the action beyond the time it will take for the element that we use in the action to become visible and accessible. During the set timeout, the action tries to access the element it is working with. As soon as the element is accessed, the waiting timeout ends.

  4. Set the "Window focus element Scale" action parameter. The element must be obtained using the WinSpy tool. Working with WinSpy is described in the Getting a Win-element section.

  5. Set the "Get related elements" action parameter. Select the "Scale1" element that was obtained earlier using the WinSpy tool and the "Daughter elements" type of connection. 

  6. Set the "Get length" action parameter. In the Collection field specify the result of the "Get related elements" action.

  7. Set the "Subtraction" action parameter. Настроить параметр действия "Subtraction". The second operand will be 1.

  8. Set the "For" loop parameter. In the Result field specify the "Subtraction" action result.

  9. Set the "Get value by index" action parameter. In the Collection field, specify the result of the "Get related elements" action, in the Index field, specify the states of the iterator of the "For" loop:
  10. Set the "Terminate" action parameters.
  11. Click "Start" in the top panel.

Result

The program robot completed successfully.

Daughter elements "Zoom in", "Zoom out", "Set scale by default" were obtained.


Example 2

  1. Change the parameter of the "Get related elements" action. Select the "Scale1" element previously obtained using the WinSpy tool and the type of connection - Parent elements.
  2. Click "Start" in the top panel.

Result

The program robot completed successfully.

Parent element "View" was obtained.

Example 3

  1. Change the parameter of the "Get related elements" action. Select the "Scale1" element previously obtained using the WinSpy tool and the type of connection - Neighboring elements.
  2. Click "Start" in the top panel.

Result

The program robot completed successfully.

The neighboring element "Status bar" was obtained.

  • Нет меток