//向左滑动
public static void swipeLeft(String time) {
sleep(1000);
int x = mDevice.getDisplayWidth();//获取屏幕的宽
int y = mDevice.getDisplayHeight();//获取屏幕的高
Log.e(TAG, "屏幕分辨率: " + x + " X " + y);
mDevice.swipe((int) (x / 1.3), y / 2, x / 6, y / 2, Integer.parseInt(time));//左滑
Log.e(TAG, "左滑");
sleep(500);
}
//向右滑动
public static void swipeRight(String time) {
sleep(1000);
int x = mDevice.getDisplayWidth();//获取屏幕的宽
int y = mDevice.getDisplayHeight();//获取屏幕的高
Log.e(TAG, "屏幕分辨率: " + x + " X " + y);
mDevice.swipe(x / 6, y / 2, (int) (x / 1.3), y / 2, Integer.parseInt(time));//右滑
Log.e(TAG, "右滑");
sleep(500);
}
//向下滑动
public static void swipeDown(String time) {
sleep(1000);
int x = mDevice.getDisplayWidth();//获取屏幕的宽
uiautomator2.0封装上下左右滑动的方法,适配所有分辨率手机
最新推荐文章于 2024-03-27 15:31:11 发布