//向左滑动
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封装上下左右滑动的方法,适配所有分辨率手机
最新推荐文章于 2022-06-14 09:59:34 发布
本文介绍了如何使用uiautomator2.0库进行滑动手势的封装,以适应不同分辨率的手机设备。通过实例代码详细展示了上滑、下滑、左滑和右滑的操作方法,确保在各种屏幕尺寸下测试的稳定性。
摘要由CSDN通过智能技术生成