Capturing Screenshot of an application and comparing it with another image

Hello Community ,

I am trying to capture a particular screen of my application and comparing it with the reference image to see if it has any differences (Pixel to Pixel image comparison). Is there any way to do so, by the way I also wanted to display both the reference image and the application image I am comparing it to be displayed in the log/report file. Can you help me in this.

Hi @Lalith ,

you can try my library for visual comparisons.
It has plenty of features (as it also supports other documents like PDF) but basic screenshot comparisons will work as well :slight_smile:

2 Likes

Hi @Many ,

I’ve been using this library and it’s pretty interesting. As part of image comparison, I need to mask a specific region in my image (let’s say center of the image something like this


and I’ve used this json format code ([

{

    "page": "all",

    "name": "Animation",

    "type": "coordinates",

    "x": 300,

    "y": 290,

    "height": 270,

    "width": 350

    }

]
)
But I’m not sure what went wrong.Could you please correct me .

Thanks,

To use the ignore area in your json, you need to pass the path to that file as an argument placeholder_file

*** Settings ***
Library    DocTest.VisualTest

*** Test Cases ***
Compare two Images and ignore parts by using masks
    Compare Images    Reference.jpg    Candidate.jpg    placeholder_file=masks.json

What your json file should do:
Create an rectangle ignore area at the position x=300 and y=290 px (counting from top left corner). The ignore area shall have a height of 270px and a width of 350px.
The ignore area will be shown as a blue box in the comparison screenshots.

What is the actual behavior or error that you are facing?

Hi,

Yes the error might help :blush:
I’m using mainly placeholder_file that I reuse on several pdf, but have some direct json this way that works:

  VAR    ${mask}    [{"name": "Area1","type": "coordinates","x": "205","y": "15","width": "160","height": "16","unit": "px"},{"name": "Area2","type": "coordinates","x": "235","y": "35","width": "140","height": "22","unit": "px"}]

The things I see is that I had issues when values where not in “value” format, and I have an unit specified.
Note that Many’s library usually throw very readable errors (for example if json can’t be proceed).

Regards
Charlie

1 Like