Checking if the element exists Version 5 (Net)

Action group: Windows


Description

The action checks if the specified element exists on the screen.

Action icon

Settings of parameters

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
ElementResource with data of selected element in applicationRobin.WinElement
Yes
Time-outTime in milliseconds to find required element.Robin.Numeric
No
Window orderSequence 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
ResultIf the value is «true», the desired element exists. If the value is «false», the desired element does not exist.Robin.Booleantrue

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 numberNumber of windowsRobot interactions
Not filled inMultiple (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 windowWith the single window
Filled with a negative number1 or multiple windowsError

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

  1. 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.


  2. Move the "If" action to the workspace and set its parameters.

    In the "Condition" field specify the "Checking if the element exists" action result.

  3. 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.

  4. 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.

  5. 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.

  • Нет меток