How to Photo Image -Pinch open and Pinch close in Android Native App automation

Hi Friends,

In my app automation ,there is new requirement to Pinch Open and close the photo image.Could you please any1 help me on this.


  1. If Pinch In the Photo Preview image ,then will show in enlarged
  2. Then Pinch Close ,back to preview image

HI Jaga,
Please try this

WebElement Image = driver.findElementById(“com.davemorrissey.labs.subscaleview.sample:id/imageView”);

        int x=Image.getLocation().getX()+Image.getSize().getWidth()/2;
        int y= Image.getLocation().getY()+Image.getSize().getHeight()/2;
        //Zoom out
        TouchAction finger1= new TouchAction(driver);, x, y-20).moveTo(Image,x,y-50);
        TouchAction finger2= new TouchAction(driver);, x, y+20).moveTo(Image, x, y+50);
        MultiTouchAction action= new MultiTouchAction(driver);
        System.out.println("Zoom Done");
        TouchAction finger3= new TouchAction(driver);, x, y-20).moveTo(Image, x, y-10);
        TouchAction finger4= new TouchAction(driver);, x, y+20).moveTo(Image, x, y+10);
        MultiTouchAction action2= new MultiTouchAction(driver);
        System.out.println("Pinch Done");

Thanks Hari for Quick Respond.

I tired but its not working.

Hari -could you have any other solution?Plz share