简体   繁体   中英

Issue while comparing two images using Java & ImageMagick

I have a simple solution to compare two images (two screenshots of Chrome browser). To get an image I use AShoot library. To compare two images I use ImageMagic tool.

public Screenshot takeScreenshot() {
        Screenshot elementScreenShot = new AShot()
                .shootingStrategy(ShootingStrategies.viewportPasting(100))
                .takeScreenshot(DriverManager.getWebDriver());

        return elementScreenShot;
    }

I use ImageMagic to compare base image with new one - actual. But very often I getting an error. Everything is ok but the problem is with corners of fields.

Example: Actual:

在此处输入图像描述

Expected:

在此处输入图像描述

Result (ImageMagic compare result):

在此处输入图像描述

As you can see, the problem is with few pixels in the corner of the field. I tried many tricks but nothing happens.

I observe that issues occur only on the Chrome browser. On Mozilla everything it's OK. It seems that there is a problem in rendering our application in the Chrome browser. For 10 executions of this same site, 7/10 have differences in field corners.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM