takeWebElementScreenshot customkeyword from aShot plugin is not working as expected

Your finding proves that the “Image Comparison using AShot Keyword” does not take the device pixel ratio into account appropriately. Possibly you shouldn’t use it.


I looked at the source code of the plugin

I found this code is problematic.

See the signagure of takeScalingScreenshot keyword:

static void takeScalingScreenshot(String filename, float dpr, FailureHandling flowControl = FailureHandling.OPTIONAL){
		try{
			def screenshot = new AShot()
					.shootingStrategy(ShootingStrategies.scaling(dpr))
					.takeScreenshot(DriverFactory.getWebDriver())
			saveScreenshot(filename, screenshot)
		}catch(ex){
			handleError(ex, flowControl)
		}
	}

This has a parameter named dpr, which stands for device pixcel ratio. the dpr parameter is actually used when AShot object is to take screenshot. This is the way ALL of method should follow.

However all other Keyword methods in this plugin doesn’t take device pixcel ratio into account. The author of this program was a bit lazy, I guess. He did not test the code using 2 machines with different screen resolution settings as @zahid.asim did.

Therefore I would conclude that this plugin is incomplete. This will never work appropriately if you use the keyword on 2 machines with different scaling of screen resolution.