java-clienk 实现通用放大逻辑
放大
/**
* 自定义实现通用放大方法
*/
public static void zoomOut() {
// 1、实例化多点触摸对象
MultiTouchAction multiTouch = new MultiTouchAction(androidDriver);
// 2、得到当前屏幕高度
int scrHeight = androidDriver.manage().window().getSize().getHeight();
// 3、得到当前屏幕的宽度
int srcWidth = androidDriver.manage().window().getSize().getWidth();
int x = srcWidth / 2;
int y = scrHeight / 2;
int yOffset = 100;
if (y - 100 < 0) {
yOffset = y;
} else if (y + 100 > scrHeight) {
yOffset = scrHeight - y;
}
// 第一根手指的滑动
TouchAction action0 = new TouchAction(androidDriver).press(PointOption.point(x, y))
.moveTo(PointOption.point(x, y - yOffset)).release();
// 第二根手指的滑动
TouchAction action1 = new TouchAction(androidDriver).press(PointOption.point(x, y))
.moveTo(PointOption.point(x, y + yOffset)).release();
multiTouch.add(action0).add(action1);
multiTouch.perform();
}
缩小