pazone / ashot

WebDriver Screenshot utility. Take screenshots, crop, prettify, compare
Other
636 stars 157 forks source link

Need better DiffMarkupPolicy algorithm #409

Open xtianus opened 1 year ago

xtianus commented 1 year ago

Sometimes, when taking two screenshots of the same page with the same PC in Chrome I get slightly different bitmaps for text. This is an example diff:

image

The reason might be that antialias is not always the same. These are the two zoomed screenshots:

Screenshot 2023-08-18 at 5 16 11 PM

Screenshot 2023-08-18 at 5 16 43 PM

I can notice some color in the former that is absent in the latter. Using setDiffSizeTrigger() doesn't help because it only counts the total number of points and this value can be very big when there is a long paragraph.

xtianus commented 1 year ago

As a workaround for this specific issue I'm turning all pages to B&W with this injected CSS:

document.documentElement.style.filter = 'grayscale(100%)';

This is giving me no diff errors on the above text anymore.

I'm still getting some diffs on other parts of the page that, maybe because of animations, turn out to be a little different than before due to timing I guess.

So maybe I'd like to have a diff algorithm that counts the changed pixels locally, for example for each 100x100 square of the image.