How to find an image in a specific location when identical selectors exist


I am trying to write an automation that relies on checking an image to determine if the next step should be continued or not. For example let’s say my bot needs to wait to see this image before proceeding:
(see below screenshot)

However, I cannot just use a Find Image activity and move on, because this image occurs in several parts of a web page, and in some events the surrounding selectors are identical.

I need a way to look at the very first row only on this webpage, and see if the checkmark image exists only in that row. For example see this image (I will link the demo at the bottom of the post)

As you can see there is multiple of the same image.

I cannot find anyway to differentiate the first and third row of this table. The selectors there are identical.

I tried using the Get Position activity to get the coordinates of where my specific image resides (1st row), and then entering those coordinates within the ClippingRegion within the Find Image activity but I could not get this to work.

Link to demo:

Thank you.

Hi @rmckinnon
Is there any columnname or header above the first row…
And if its there we can try with anchor base Activity with find image of a text in column header which is to be kept in the left side of anchor base activity and in right side we can use Find image Activity Activity that would give us boolean value as output…so that we would know whether its ticked or not

Hope this would help you buddy
Kindly revert for any queries or clarification
Cheers @rmckinnon

@rmckinnon Could you Data Scrape the table. Use a For Each Row activity to iterate through each. Assign a variable at the image location. If the variable equal a certain condition do as you wish?

I’m not sure if that is viable for me. In my actual use case I will be given a webpage that I have no access to modify source code wise. The demo I showed is an html version of what I’ll be working with, and I noticed the images, src, alt id, anything is all exactly the same. They do separate the table into odd and even rows but that still won’t work because I’ll get false positives again.

There has to be an activity that just looks for an image or element within a specified region only.

Easiest method, I think, would be to look in UiExplorer for the tableRow attribute. If it has a tableRow attribute, then it’s simple. - use that in the selector to check the first one using tableRow as the first row number.

If you need to dynamically check the box, then you will need to use Get Attribute for tableRow of another value in that row which is unique. Then, use that variable in the selector for tableRow of the check box. - you can do all the checkmarks by running it through a loop.

If the tableRow attribute (or similar) is not available, then you should explore using the Find Children activity. This allows you to get all elements for a certain tag, but the logic for this can sometimes be more complicated.


1 Like


OK say the name the selector on the row that contains the image I want to check is:

<webctrl parentid='tableRecentImport' tableRow='3' tag='IMG' />

Like you said I think the tableRow attribute will be sufficient. However,I’m still confused how to proceed to check if a certain image exists only in that row and not detect said image in other rows.

A little more information of what I’m trying to accomplish: I am processing files onto a server and am using the most recent entry’s image to decide if the process has completed successfully or not. So in the spot I’m checking the image will change.

Would appreciate if you could explain this method a little more, thanks.

So let us assume the ‘first’ tableRow number could potential change. You will want to scrape the data to a table, sort by the date (unless you can assume the data is always first).

Knowing what the date value is, you can use that value in the Get Attribute activity.
Using your example:

After scraping the data, you can take the first row and last column.
where ‘9’ is the index of the last column (you would want to verify this)

Using that string value, you can use in the selector for the Get Attribute - probably in the aaname. You will also need to edit the selector as an expression where there are quotations around it, by clicking in the Selector property box rather than editing in the Selector Editor… if that makes sense.
"<webctrl aaname='06/17/2019 09:33 AM' tag='DIV' />"
will become this with the value from the scraped data:
"<webctrl aaname='"+dt1.Rows(0)(9).ToString+"' tag='DIV' />"

…and for the attribute use “tableRow” and store it to a variable.

After that, you should have the value for tableRow of the latest item in the table, which will be ‘3’ if 3 is the first row in the table. Then, concatenate that value in the selector just the same.
"<webctrl parentid='tableRecentImport' tableRow='"+tableRow.ToString+"' tag='IMG' />"

So, that is the more dynamic method, if you don’t want to hardcode the tableRow value. And, you can also look at other values in the data table, if you want to only select specific rows on certain criteria.

I hope that explains this method better.