Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.

...

Get related elements Version 2 (Net)

Группа действий: Windows  Подгруппа "Работа с win-элементами"

Описание

Действие проверяет указанный элемент и возвращает связанные с ним элементы (родительские/дочерние/соседние)

Пример на "Блокноте":

Image Removed

Для элемента "Масштаб" соседним элементом будет "Строка состояния". Родительский элемент - "Вид". Дочерние элементы: "Увеличить", "Уменьшить", "Восстановить масштаб по умолчанию".

Иконка действия

Image Removed

Параметры

Входные параметры

Элемент                Параметр, который хранит данные Win-элемента, координаты которого будут проверяться

Тип связи              Выпадающий список с элементами: "Родительские элементы", "Дочерние элементы", "Соседние элементы"

                              Если выбрана "Родительский элемент", то в результате вернется коллекция с win-элементами, которые являются родителями для указанного элемента

                              Если выбрана "Дочерние элементы", то в результате вернется коллекция с win-элементами, которые являются дочерними для указанного элемента

                              Если выбрано "Соседние элементы", то в результате вернется коллекция с win-элементами, которые являются "соседями" для указанного элемента, то есть имеют общего родителя

Глубина поиска   Уровень вложенности связанных элементов, до которого будет производиться поиск. Положительное целое число от 1 до бесконечности 

                             По умолчанию - "1". Глубина не учитывается, если в "Тип связи" выбрано значение "Соседние элементы"

                             Если глубина, указанная в параметре, больше фактической глубины в приложении, то берутся все элементы до фактической глубины 

Тайм-аут              Время в миллисекундах, в течение которого будет происходить поиск нужного элемента

Номер окна         Порядковый номер окна, с которым будет взаимодействовать действие, если обнаружено несколько окон

                             При этом действие ищет только те окна, в которых должен находиться элемент согласно его параметрам

                             Положительное целое число от 1. По умолчанию - "1"

Выходные параметры

Результат          Коллекция win-элементов

...

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:

Image Added

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

Action icon

Image Added

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»
"Neighboring items" value is selected in the
«Type
"Type of
connection»
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

Особые условия использования

Если пользователь в "Тип связи" выбирает "Родительские элементы" и у указанного win-элемента отсутствует родитель, то в результате вернется пустая коллекция.

Если пользователь в "Тип связи" выбирает "Соседние элементы" и у указанного win-элемента отсутствуют соседи, то в результате вернется пустая коллекция.

Если пользователь в "Тип связи" выбирает "Дочерние элементы" и у указанного win-элемента отсутствуют дети, то в результате вернется пустая коллекция.

Метод обхода графа - в ширину.

Пример работы действия

Image Removed



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 

Image Added

  • 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
  • Пользователь указал элемент L, "Глубина поиска"=3, "Тип связи" = "Родительские элементы". Результат - коллекция с элементами E, B, A
  • Пользователь указал элемент B, "Глубина поиска"=2, "Тип связи" = "Дочерние элементы". Результат - коллекция с элементами 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" = "Родительские элементы". Результат - пустая коллекция
  • Пользователь указал элемент A, "Тип связи" = "Соседние элементы". Результат - пустая коллекция
  • Пользователь указал элемент I, "Тип связи" = "Дочерние элементы". Результат - пустая коллекция

Пример использования 

Задача

Открыто окно с названием "Блокнот". Необходимо получить соседние, дочерние и родительские элементы элемента "Масштаб".

Решение

Воспользоваться действием "Получить связанные элементы". 

Реализация

  1.  Собрать робота, состоящего из действий: 
    Image Removed
  2. Настроить параметры действия "Run":
    Image Removed
  3. Настроить параметр действия "Window focus element". Элемент необходимо получить с помощью инструмента WinSpy. Работа с WinSpy описана в разделе Получение win-элемента. Установка тайм-аута, в целом, не приводит к увеличению времени выполнения действия сверх того времени, которое потребуется для того, чтобы элемент, который мы используем в действии стал видимым и доступным. В течение установленного тайм-аута действие пытается получить доступ к элементу с которым работает. Как только появляется доступ к элементу, ожидание тайм-аут заканчивается.
    Image Removed
  4. Настроить параметр действия "Window focus element Scale". Элемент необходимо получить с помощью инструмента WinSpy. Работа с WinSpy описана в разделе Получение win-элемента.
    Image Removed
  5. Настроить параметр действия "Get related elements". Выбираем ранее полученный с помощью инструмента WinSpy элемент "Масштаб1" и тип связи - Дочерние элементы:
    Image Removed
  6. Настроить параметр действия "Get length". В поле Коллекция или массив, указываем результат действия "Получить связанные элементы":
    Image Removed
  7. Настроить параметр действия "Subtraction". Второй операнд будет 1:
    Image Removed
  8. Настроить параметр цикла "For". В поле Конечное значение, указываем результат действия "Subtraction":
    Image Removed
  9. Настроить параметр действия "Get value by index". В поле Коллекция, указываем результат действия "Get related elements", в поле Индекс, указываем состояния итератора цикла "For":
    Image Removed
  10. Настроить параметры действия "Terminate":
    Image Removed
  11. Нажать на кнопку "Старт" в верхней панели. 

Результат

Программный робот отработал успешно.

Image Removed

Дочерние элементы "Увеличить", "Уменьшить", "Восстановить масштаб по умолчанию" получены.

Пример 2

  1. Изменить параметр действия "Get related elements". Выбираем ранее полученный с помощью инструмента WinSpy элемент "Scale1" и тип связи - Родительские элементы. 
    Image Removed
  2. Нажать на кнопку "Старт" в верхней панели. 

Результат

Программный робот отработал успешно.

Image Removed

  Родительский элемент "Вид" получен.

Пример 3

  1. Изменить параметр действия "Получить связанные элементы". Выбираем ранее полученный с помощью инструмента WinSpy элемент "Scale1" и тип связи - Соседние элементы. 
    Image Removed
  2. Нажать на кнопку "Старт" в верхней панели. 

Результат

Программный робот отработал успешно.
Image Removed

  • 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:
    Image Added
  2. Set the "Run" action parameters.
    Image Added
  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.
    Image Added
  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.
    Image Added
  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. 
    Image Added
  6. Set the "Get length" action parameter. In the Collection field specify the result of the "Get related elements" action.
    Image Added
  7. Set the "Subtraction" action parameter. Настроить параметр действия "Subtraction". The second operand will be 1.
    Image Added
  8. Set the "For" loop parameter. In the Result field specify the "Subtraction" action result.
    Image Added
  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:Image Added
  10. Set the "Terminate" action parameters.
    Image Added
  11. Click "Start" in the top panel.

Result

The program robot completed successfully.

Image Added

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.Image Added
  2. Click "Start" in the top panel.

Result

The program robot completed successfully.

Image Added

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.Image Added
  2. Click "Start" in the top panel.

Result

The program robot completed successfully.
Image Added

The neighboring element "Status bar" was obtainedСоседний элемент "Строка состояния" получен.