ashot icon indicating copy to clipboard operation
ashot copied to clipboard

Image comparison is failing for same image in same navigator due to Pixels difference

Open aymen3redlean opened this issue 6 years ago • 6 comments

Hello,

we use ashot in selenium project to compare two images in a specific test case.

In same case, the image are the same but image comparison fails due to Mismatched pixels

Is the any way to fix this? Or to reduce sensibility in image comparison?

aymen3redlean avatar Sep 13 '19 13:09 aymen3redlean

@aymen3redlean could you please provide more details? what is actual reason of the mismatch in your case?

valfirst avatar Sep 19 '19 11:09 valfirst

Hello, According to the comparison, there are some pixels were be shifted from their original positions. Is there a way to ignored this case and say that the two images are same?

aymen3redlean avatar Sep 19 '19 14:09 aymen3redlean

@aymen3redlean do you have any idea why pixels are shifted? also could you please post the code you use to compare images?

valfirst avatar Sep 19 '19 14:09 valfirst

The screenshots are the same but taken in different time which can be the origin of the shift.

Please find in below the comparison code:

try {
			ImageDiffer imgDiff = new ImageDiffer();
			ImageDiff imageResult = imgDiff.makeDiff(
					ImageIO.read(new File(RunFolderPath + "\\" + imageTabName + "_1_" + level + ".png")),
					ImageIO.read(new File(RunFolderPath + "\\" + imageTabName + "_2_" + level + ".png")));

			if (imageResult.hasDiff()) {
				BufferedImage y = imageResult.getMarkedImage();
				
				ImageIO.write(y, "PNG", new File(imageTabName + "_diff.png"));
				
			}

		} catch (Exception e) {
			
			new Exception();
		}

aymen3redlean avatar Sep 19 '19 14:09 aymen3redlean

@aymen3redlean you can try changing the value of diff size trigger:

PointsMarkupPolicy diffMarkupPolicy = new PointsMarkupPolicy();
diffMarkupPolicy.setDiffSizeTrigger(<put_your_value_here>);
ImageDiffer imgDiff = new ImageDiffer().withDiffMarkupPolicy(diffMarkupPolicy);
...

valfirst avatar Sep 19 '19 14:09 valfirst

I am facing the same issue, how should we use setDiffSizeTrigger, is there any threshold to comparison we can give, like fail if 90% of image doesn't match, right now it fails even if the text shifts a bit

clickOnSellerDetails_diffImage

varshasaha avatar Apr 22 '20 18:04 varshasaha