Is there a specific library for automates visual regression testing with robotframework of your responsive web UI by comparing DOM screenshots over time?
I want to use chromium as a browser and that is the baseline and want to compare (buttons, fields, etc) it with the web view of webkit, Safari or FireFox.
First part is easy, Browser like most Robot Framework libraries has a Take Screenshot keyword
I’m not aware of anything that will provide an image compare out of the box, but you can do that in python, so you could create a python keyword that compares two screenshots (images), I found this example, how-to-compare-two-images that uses the python numpy module, they had 2 different sized images, but if you set the size of your browser window to always be the same then you can skip the reshape step and just compare the images, i’m not sure what the number returned is, probably the number of different pixels, so if you divide by the total pixel count of one image that would potentially give you a percentage different store this in a variable ${pct_diff} then to pass /fail your test use the builtin keywords:
${result} = Evaluate ${pct_diff} < 10 #set you tolerance level here
Should Be True ${result}
There’s a library called pixelmatch that uses a cut down version of the full Python Image Library (PIL) and I found that to be very effective for performing image comparisons, returns both a numerical value and a difference image pixelmatch · PyPI
In robot file
Library img.py
…
${diff} = Compare Images ${file2} ${file} ${file}
${diff} is a numerical value for the number of pixels that don’t match
${file2} is the reference image
${file} is the screenshot (uses the same name to create the diff image as well)