Working with Find Image Matches Activity

How to handle if the same image is present multiple times and Find Image activity needs to be used for the below scenarios? Click on the first or the last image Click on the images iteratively Get the count of the images available on the screen (for example in PDF's) All these can be achieved easily using "Find Image Matches" activity

The Find Image Activity helps to select the required image and returns an IEnumerable collection of "UiElements", which can be used to solve the scenarios mentioned above

  • Click on the first or the last Image

           

 Here, it is required to click on the first checkbox ("Bike"). Reference Image for the activity is the "checkbox" icon

Steps

      1. Drag "Find Image" activity (preferably after "Open Browser" or "Attach Window" activity)

      2. Specify the image you want to click using the "Indicate on Screen" option

      3. The output of the activity will be an IEnum of UiElements (say test_img)

      4. Drag "Click" activity and specify in the Element attribute the following - test_img. First (it will click on the first image) /test_img. Last (it will click on the last image)

 

  • Click on the images iteratively

       

Here, it is required to click on the checkboxes iteratively. Reference image for the activity is the "checkbox" icon

Steps

      1. Drag "Find Image" activity (preferably after "Open Browser" or "Attach Window" or "Open Application" activity)

      2. Specify the image you want to click using the "Indicate on Screen" option

      3. The output of the activity will be an IEnum of UiElements (say test_img)

      4. Drag "For Each" activity inside the Project (Set the Object Type to UiElement)

      5. Drag "Click" activity and specify in the Element attribute specify the index used in the "For Each" which will get the images one by one and click accordingly. 

 

  • Get the count of the images available on the screen 

            

Here, it is required to get the count of the no of Units having the "Start" option selected. The reference image for the activity is the image having the "Start" option selected

Steps

     1. Open the PDF file using Open Application/Start Process activity

     2. Scroll down to the place where the images are located using Send Hotkey Activity.

     3. Drag "Find Image" activity

     4. Specify the image you want to click using the "Indicate on Screen" option

     5. The output of the activity will be an IEnum of UiElements (say test_img)

     6. Display the count inside "Write-Line"  or "Message Box" activity using test_img.Count.toString

 

Attached the sample workflow and the required files.