Image Comparison using robot framework

Hi Everyone,

I am trying to compare two images using ImageCompare library. But I want to mask some coordinates.

capture page screenshot arc_homepage.png
compare images actualsc.png arc_homepage.png placeholder_file=masks.json

But I don’t know where to place my masks.json file . Can anyone guide me?

Hi Urvashi,

I would expect with that syntax that the masks.json and the 2 .png files should be in the same folder as your robot file. If you need to put them in a different file then you would probably need to add a path to tell the library where the files are relative to ${CURDIR}

Dave.

Hi Dave,

Thank you so much for replying.
So I have everything in my same directory I just need to hide one calendar from one image and then compare. So in my json file I have written this.

{
“name”:“calendar”,
“width” : 850,
“height” : 1184,
“unit”: “px”
}

I am getting this error:
The compared images have different dimensions:
reference:(740, 1582, 3)
candidate:(744, 1600, 3)

and the script I wrote was:
capture page screenshot arc_homepage.png
compare images C:/Robot Projects/ROA_Apps_Automation/ARC/TestSuites/actualsc.png arc_homepage.png placeholder_file=C:/Robot Projects/ROA_Apps_Automation/ARC/TestSuites/masks.json

I mentioned absolute path of my json file

Hi Urvashi,
seems like the images have different sizes (the width/height are different)
By default, the library will return a failure for that.

It is only possible to compare images with the same dimensions.

What is your expectation if two images with different sizes are compared?
Shall they be re-sized (to have the same dimensions) and compared afterwards?

By the way:
That ImageCompare Library

is just a reduced version from my document testing library

To be honest, I did not maintain the imagecompare that much since a while.
But I can start to implement new features there if there is a need to do that.

2 Likes

Hi Many,

So my requirement is that I need to compare image for me dimension doesn’t matters. So there is a drop-down in my web app which should have a default value but somehow its a combo box and i am not able to fetch any text or anything to validate that. So I thought of comparing two images like one screenshot will be taken through keyword (capture screenshot) and other I will take manually. Also i tried to mask some dynamic elements on that page. but there is some minor dimension difference. like this

The compared images have different dimensions:
reference:(759, 1600, 3)
candidate:(744, 1600, 3)

I just want to make sure that default value of that dropdown which is ‘NO SELECTION’ that should b present in both images (image captured by robot and image screenshot i am attaching manually.

Also what else should i add in my json file apart from height , width and units? Percentage? or tolerance I am not sure much about these

Hi Urvashi,

It might be a good idea to attach a copy of actualsc.png and arc_homepage.png to give Many a better idea if the two images you’re trying to compare.

I can probably guess, the issue with the images not being the same size is an alignment issue and if one image is smaller not knowing where/how to align the smaller one over the bigger one? I’m guessing if you aligned the top left corners of both images the drop down in the smaller image won’t be in the same position as the same drop down in the bigger image?

Dave.

Hi Dave,

So you see that their is only minor height difference:

The compared images have different dimensions:
reference:(759, 1600, 3)
candidate:(744, 1600, 3)

Maybe we find a way to verify the text properly without image comparison.
What Library are you using for your Tests?
Selenium Library or Browser Library?

2 Likes

Hi Many,

I followed your youtube video…It worked for me …My issue is resolved. Thank you :slight_smile:

1 Like

Also Is there any professional certification of Robot framework?