manykarim / robotframework-doctestlibrary

Robot Framework DocTest library. Simple Automated Visual Document Testing.
Apache License 2.0
46 stars 20 forks source link

Compare Images Failed - how to ignore the false positive differences? #40

Closed lovelyplanet2019 closed 2 years ago

lovelyplanet2019 commented 2 years ago

Basically, I just want to compare the content within the webpage, the browser border/windows date time/taskbar isn't concern.

How do I set robot to ignore them?

fe4db52e-ab4a-11ec-b653-751203400326_page_1_rectangles_concat

manykarim commented 2 years ago

Hi, there are different ways how to ignore parts. One very simple way, is by using an area mask. You can basically say: Ignore the top 10 % of the image. Or the left 5% of the image. That's a very simple way to ignore parts.

Check out the example here for Compare two different PDF Files with area mask https://github.com/manykarim/robotframework-doctestlibrary/blob/main/atest/Compare.robot

Compare Images testdata/sample_1_page.pdf testdata/sample_1_page_changed.pdf placeholder_file=testdata/pdf_area_mask.json

The mask file looks like that: [ { "page": "all", "name": "Job ID", "type": "area", "location": "top", "percent": 10 } ]

You will also find some explanatio here https://github.com/manykarim/robotframework-doctestlibrary#different-mask-types-to-ignore-parts-when-comparing

It is also mentioned in the video (roughly from this position) https://youtu.be/qmpwlQoJ-nE?t=377

lovelyplanet2019 commented 2 years ago

thanks I got it by simply use

[
    {
    "page": "all",
    "type": "area",
    "location": "top",
    "percent":  15
    },
    {
    "page": "all",
    "type": "area",
    "location": "left",
    "percent":  15
    },
    {
    "page": "all",
    "type": "area",
    "location": "right",
    "percent":  15
    },
    {
    "page": "all",
    "type": "area",
    "location": "bottom",
    "percent":  15
    }
]
manykarim commented 2 years ago

Cool, happy that this solved your problem :)