Search if an image exists on a webpage but in a specified location only

Hi,

I want to be able to look at a specified portion of a webpage, and then check if an image exists. What’s actually happening is my workflow is detecting when the image is anywhere on the webpage.

For example, see this screenshot showing the giant green coffee cup:

This is my workflow:

When I run my workflow, I get my “Image detected” confirmation as I wanted. But if I change the giant coffee cup to a different color:

and re-run my workflow, I still get my “Image detected” confirmation. I do not want this, I only want to check for the image in a specified region (in this case the giant coffee cup area).

Is there any way to do this?

Here’s the link to the website and my workflow:

Main.xaml (70.6 KB)

Thanks!

Hi @rmckinnon,

Take a look at this.Main (1).xaml (19.0 KB)

Hi @rmunro,

Thanks for the quick response. Unfortunately this is not what I am looking for. I’ll try to explain it more clearly. When looking on the website link provided upon closer inspection the bigger green coffee cup and the smaller green coffee cup are actually the same exact image. My goal is to only check if the green coffee cup image exists in the bigger selection.

The problem with your solution is you just check if that coffee cup image exists, it is not enough for me to know whether the coffee cup exists or not due to the duplicate. I need to know if the coffee cup image exists in a very specific portion of the screen only

Thanks, apologies for being unclear in my question.

Hi @rmckinnon

Have you experimented with changing the Target->ClippingRegion?

1 Like

I saw this, but am not sure how to figure out what the clipping region bounds would be. How can I do that?

Is it possible to modify the selector (e.g. the big image is in a different div id)?

1 Like

In that case, the image is the same so anything related with the find image will not be possible. If the images should have a different selector or selector name. You can use different selector methods.

@rmckinnon use the Activity - Element Exists. With the following selector

<html app='chrome.exe' title='Switch Main Product Image When Clicking On A Variation Thumbnail*' />
<webctrl id='currentImg' tag='IMG' alt='Blue' />

The Alt tag and title change with the color of the cup.

image
image

Maybe I should repost my question. How can I make this more clear.

Take a look at this screenshot:

That picture leads you to this image path: /wp-content/uploads/2017/07/teacup4.png

Now this is the result when I inspect element on the SMALL green cup that’s labeled green underneath:

That pictures leads you to this image path: /wp-content/uploads/2017/07/teacup4.png

So as you can now see, these are identical images. So whenever I try to use a find image activity, UiPath is just looking for this specific image. Cool. But I don’t want that. In the big cup part of the webpage ONLY I want to see if the green cup image (/wp-content/uploads/2017/07/teacup4.png) appears only in that spot!

For example:

If my workflow ran and had this currently on the webpage while searching for a green cup I want it to return FALSE because the green cup image does not exist in the section I want to look in, as you can see the larger picture is clearly the red cup.


Am I making sense, I feel like I’m not communicating well enough :frowning:

@nlee1131 Sorry I can’t figure out what you mean by that. Either way the reason of the problem is because when you select the big image, it’s just an identical copy of the 4 different images here

So when you try to do a find image for one of these cups, it will always return True because there always exists that element. There has to be some way to say hey in the bounds of the big image only, check to see if this specific image resides only in that area, and return false if not. But I can’t figure out how to say that :confused:

There is the Target tool that has something called ClippingRegion which may work, but it just gives me an empty box of coordinates. I can’t seem to find anything that could help fill out this box for me. image

Thanks

I understand what you are asking/following along.

Don’t have the Activity search for the image… Have it search for a specific element on the page. The image’s source name, alt, and titles are different depending on the thumbnail selection. You can set you selector to which you like. In my example below I picked Blue.

ImageFinder.xaml (6.2 KB)


2 Likes

@rmckinnon

So did Jarzzz’s selector not work?

@Jarzzz @nlee1131 Yes this works for this use case, and thank you so much for that. I am trying to look for a solution that works in the event that the image’s source name, alt, titles, anything is all exactly 100% the same and be able to differentiate at that point (which is why I was asking about checking for an image in an exact area of a webpage strictly). That however is out of the scope of this question and I’ll ask another one to question specifically that as I wasn’t aware this example problem could be solved without doing that. I’m accepting Jarzzz’ answer for this particular problem.

Thanks again!

1 Like

Happy to help. I had a feeling this wasn’t your actual use case.

What you are looking for is possible… Just have to set the UIElement to the container in which you are searching for the image. At the end of the day its really just about playing with the selector.

Glad you found a solution!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.