How to compare screenshots with ashot changing the expected precision?

1.7k Views Asked by At

I'm using Ashot with Selenium to compare a canvas graph generated by a web page with an image saved in the system. We've used the ashot API to generate this saved image for further comparison, avoiding differences in the future.

But in my team there are developers that use Windows, others that use Linux and, even using the same browser version, the graph rendered is slightly different (color strength, font rendering) and the comparison (using ImageDiffer.makeDiff()) of the two images results in different results in different OS's because of those render differences (I guess the problem is it).

Is there any way to compare the two images with Ashot ignoring those small differences? I mean: changing the precision of comparison?

1

There are 1 best solutions below

1
On BEST ANSWER

Robson! You probably are looking for this option withDiffSizeTrigger. It sets the maximum number of distinguished pixels when images are still considered the same.

Take a look here

As an example:

ImageDiff diff = new ImageDiffer().makeDiff(expected, actual).withDiffSizeTrigger(__numbers_of_pixels__)