Appium Image comparision support

Hi All,
Is there a way by which we can compare images in a native app using Appium ?

Appium Directly don’t provide any file/Image comparison, but you can use below code to compare images

File f = new File("C:/share/srikanthAutomation/ActualOutput/ImageAtRunTime.png");
    File f1 = new File("C:/share/srikanthAutomation/ExpectedOutput/ImageAlreadySaved.png");
    try {
        System.out.println(FileUtils.contentEquals(f, f1));
    } catch (IOException e) {
        // TODO Auto-generated catch block

Thanks Srikanth for the prompt response
The code snippet you provided would compare entire screen

In my case I was to check if a particular icon/image is displayed on the screen or not
please suggest if any method can be used to achieve the same

@shavish, Appium do not support page comparison, you can capture screenshot using appium automation but to test screen you can use other tools like sikuli,applitools,imagemagick etc.

FYI, those interested in this may want to follow this issue: It would be, in a way, a way to validate image on screen by treating it as an Appium “element”.

The Best way is to Take a Screen Shot and compare the Screen shots…
Try this
File scrOne = driver.getScreenshotAs(OutputType.FILE);
BufferedImage imgOne =;
File scrTwo = driver.getScreenshotAs(OutputType.FILE);
BufferedImage imgtwo =;
DataBuffer dafileInput = imgOne.getData().getDataBuffer();
int sizefileInput = dafileInput.getSize();
DataBuffer dafileOutPut = imgtwo.getData().getDataBuffer();
int sizefileOutPut = dafileOutPut.getSize();
Boolean matchFlag = true;
if (sizefileInput == sizefileOutPut) {
for (int j = 0; j < sizefileInput; j++) {
if (dafileInput.getElem(j) != dafileOutPut.getElem(j)) {
matchFlag = false;
return matchFlag;
Returs a True Value for same image

Hi @shavish, as @Priyank_Shah has said, you could capture screenshots with Appium and compare them with other tools.
I’m using this approach in to integrate screenshots assertions in Appium tests, using needle and pillow libraries. It allows to compare full screnshots or a single element with previous saved screenshots, e.g.:

element = self.driver.find_element_by_id('element_id')
self.assertScreenshot(element, 'custom_screenshot_name')

You have more info about visual asserts methods in

It’s a python solution, but the implementation would be similar in other languages.