История страницы
...
Checking if the element exists Version 5 (Net)
Группа действийAction group: Windows Windows
Описание
Действие проверяет, существует ли на экране указанный элемент.
Иконка
Параметры действия
Входные параметры
- Поле "Элемент" - Ресурс который хранит данные о выбранном элементе приложения.
- Поле "Тайм-аут" - Время в миллисекундах, в течение которого будет происходить поиск нужного элемента.
- Поле "Номер окна" - Порядковый номер окна, с которым должно работать действие.
Выходные параметры
Поле "Результат" - Если значение равно «true», искомый элемент существует. Если значение равно «false», искомого элемента не существует.
Настройки
...
Description
The action checks if the specified element exists on the screen.
Action icon
Settings of parameters
Property | Description | Type | Filling example | Mandatory field |
Parameters | ||||
Element | Resource with data of selected element in application | Robin.WinElement | Yes | |
Time-out | Time in milliseconds to find required element |
. | Robin.Numeric |
No |
Window order | Sequence number of the window that the action should work with. If you do not specify the window number, the first window will be checked. The numbering starts from 1. | Robin.Numeric |
No |
Results |
Result | If the value is «true», the desired element exists. If the value is «false», the desired element does not exist. | Robin.Boolean | true |
Особые условия использования
Робот вернет ошибку, если:
- окно не найдено,
- введен несуществующий номер окна.
Действие ищет на экране элемент, запрашиваемый пользователем. Пользователь вводит свойства искомого элемента в поле «Элемент» . Действие возвращает результат «true», когда элемент найден. Если искомый элемент не находится, то результат действия будет «false».
Если найдено несколько элементов, которые подходят под указанные параметры, действие не должно вызывать ошибку. Действие возвращает значение "true".
Если в поле указан номер окна =1, а элемент находится в другом окне, то действие вернет "false".
Если указан номер окна за диапазоном количества окон (>), то взаимодействие происходит с первым открытым окном.
Если открыто одно окно, то параметр "Номер окна" игнорируется, не выпадет ошибка, НО в случае, когда введено отрицательное значение, робот выдаст ошибку.
...
Окна идут в порядке, в котором запускались.
Пример использования
Задача
Открыто окно. Необходимо определить существует ли на нем элемент.
Решение
Воспользоваться действиями "Проверить существование элемента", "Если", "Сообщение".
Реализация
Перенести действие "Проверить существование элемента" и заполнить его параметры.
Элемент необходимо получить с помощью инструмента WinSpy. Работа с WinSpy описана в разделе Получение win-элемента.
Установка тайм-аута, в целом, не приводит к увеличению времени выполнения действия сверх того времени, которое потребуется для того, чтобы элемент, который мы используем в действии стал видимым и доступным. В течение установленного тайм-аута действие пытается получить доступ к элементу с которым работает. Как только появляется доступ к элементу, ожидание тайм-аут заканчивается.
Special conditions of use
The robot will return an error if:
- the window is not found,
- an invalid window number is entered.
The action searches the screen for the element requested by the user. The user enters the properties of the searched item in the "Item" field . The action returns the result "true" when the element is found. If the item is not found, the result of the action is "false".
If multiple items are found that match the specified parameters, the action should not cause an error. The action returns the value "true".
If the field specifies window number =1 and the item is in a different window, the action will return "false".
If the window number is specified outside the window number range (>), the first open window is interacted with.
If one window is open, the "Window number" parameter is ignored, no error will be thrown, BUT if a negative value is entered, the robot will return an error.
Window number | Number of windows | Robot interactions |
---|---|---|
Not filled in | Multiple (2+) | With the first open window |
Filled in correctly (1+) | Multiple (2+) | With the specified window |
Filled with invalid window number (10) | Multiple (2) | With the first open window |
Filled in correctly (1+) | 1 window | With the single window |
Filled with a negative number | 1 or multiple windows | Error |
The windows go in the order in which they were started.
Example of use
Task
There is an open window. Determine if the element exists on it.
Solution
Use the "Checking if element exists", "If", "Show message" actions.
Implementation
Move the "Checking if the element exists" action to the workspace and set its parameters.
Get the element using the WinSpy tool. Find more on how to work with the WinSpy in section Get Win-element.
Setting a timeout does not, in general, increase the execution time of an action beyond the time it takes for the item we are using 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 item is available, the waiting timeout expires.
Move the "If" action to the workspace and set its parameters.
In the "Condition" field specify the "Checking if the element exists" action result.
Move the "Show message" action to the "True" branch.
In the "Message text" field specify "Item found". This way, if an item is found in the window, the robot will display the message.
Move the "Show message" action to the "False" branch.
In the "Message text" field specify "Item not found". This way, if the item is not found in the window, the robot will display the message.
Click "Start" in the top panel. The final robot scheme will look like this:
Result
The program robot completed successfully.
The element is found. The robot displayed the appropriate message
...
Перенести действие "Если" и заполнить его параметры.
В поле условие, указываем результат действия "Проверить существование элемента".
...
В ветку "Истина" перенести действие "Сообщение".
В поле "Текст сообщения" указать текст "Элемент найден". Таким образом, если элемент будет найден в окне, то робот выведет данное сообщение.
...
В ветку "Ложь" перенести действие "Сообщение".
В поле "Текст сообщения" указать текст "Элемент не найден". Таким образом, если элемент не будет найден в окне, то робот выведет данное сообщение.
...
Нажать на кнопку "Старт" в верхней панели. Итоговая схема робота будет выглядеть таким образом:
Результат
Программный робот отработал успешно.
Элемент найден. Робот вывел соответствующее сообщение.