This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
4 / 4
May 2018

Can anyone please post example for pinch or zoom
can we do it around elements or with specific coordinates

thanks

  • created

    May '18
  • last reply

    May '18
  • 3

    replies

  • 293

    views

  • 2

    users

What have you tried? Have you looked into TouchActions?

You probably want to use the 6.0.0 beta java client as well… the touch actions match up between them. Not sure how well tested java client 5 is with appium 1.8.x

public static void pinch(AppiumDriver<?> driver) {
	int scrHeight = driver.manage().window().getSize().getHeight(); // To get the mobile screen height
	int scrWidth = driver.manage().window().getSize().getWidth();// To get the mobile screen width
	MultiTouchAction multiTouch = new MultiTouchAction(driver);
	TouchAction touchAction4 = new TouchAction(driver);
	TouchAction touchAction3 = new TouchAction(driver);
	touchAction3.press(100, 100).waitAction(Duration.ofSeconds(1)).moveTo(scrWidth / 2, scrHeight / 2).release();
	touchAction4.press(scrWidth - 100, scrHeight - 100).waitAction(Duration.ofSeconds(1))
			.moveTo(scrWidth / 2, scrHeight / 2).release();
	multiTouch.add(touchAction3).add(touchAction4);
	multiTouch.perform();
}

HERE IS MY PINCH FUNCTION