How To Zoomin And Zoom Out Using Appium

Hi Guys ,
I have Requirement where i need to zoom in and zoom out the image so can any let me how i can achieve this using appium zoom method i tried it several times but no luck !!! Find my code below

iDriver.zoom(10, 15);
even i tried with pinch method but it didn’t work

Thanka in advance

I have done the same …zoom and pinch doesn’t work on any image.While working on the screen driver.zoom(element) & pinch(element), are working like as drag and drop in my application.

But by giving coordinates,working well…!!!
driver.zoom(12,75) & pinch(34,56) are working fine for me.

Hope expecting suggestions on this…?
@kirill @willosser

I wish I could help, but I haven’t used zoom nor pinch yet. Bhaskar’s solution looks reasonable.

1 Like

zoom and pinch didn’t worked for me I’m using MultiTouch functionality that is working fine for me :smile:

1 Like

how to Zoom the image in appium
i am useing the driver.zoom(200,300);but is not working

Can you help me with the code? how you zoom using multitouchAction functionality?
I’m new to appium and i’m facing this problem, not getting solution where i searched everywhere.
Please help me out


Just before using zoom and pinch ,
just give a single touch to the element that you need to zoom in or pinch
Here is what i have done and works perfectly…

List imageParent = (List) getDriver().findElements(By.className(“”));
WebElement imageChild = imageParent.get(0).findElement(By.className(“android.widget.ImageView”));
int leftX = imageChild.getLocation().getX();
int rightX = leftX + imageChild.getSize().getWidth();
int upperY = imageChild.getLocation().getY();
int lowerY = upperY + imageChild.getSize().getHeight();
int middleY = (upperY + lowerY) / 2;
int middleX = (leftX + rightX) / 2;
TouchAction action0=new TouchAction(getDriver()).press(middleX,middleY).release();

but this is not working for mobile web application.Is there any other way to do this?

Try with the new Actions API

I am doing in C# and my visual studio is 2015.

I am trying to zoom in and zoom out using the MultiTouchAction on the Android Device(android version 8.1.0).I am able to zoom but cant zoom out.Can anyone help.

Below is the snippet.
MobileElement image = driver.findElement(By
int center_X=image.getLocation().getX()+(image.getSize().width/2);
int center_Y=image.getLocation().getY()+(image.getSize().height/2);

	MultiTouchAction multiTouchAction = new MultiTouchAction(driver);
	TouchAction zoomOut = new TouchAction(driver);,center_Y-10)).moveTo(point(center_X,center_Y-200)).release();
	TouchAction zoomIn = new TouchAction(driver);,center_Y+10)).moveTo(point(center_X,center_Y+200)).release();
1 Like

I am trying zoom out a map for iOS automation. Any suggestions ?

Duration.ofMillis(0) ======> This one shows error. Any inputs to solve it ?