UiSelector移动设备九宫格解锁

2022-04-13  本文已影响0人  测试探索

一、手机操作

1.1息屏
d.screen_off()
1.2点亮屏幕
d.screen_on()
1.3点亮屏幕并解锁
d.unlock()
1.4获取当前屏幕状态,屏幕点亮为True,屏幕熄灭为false
print(d.info.get("screenOn"))
1.5点击home键
d.press("home")
1.6点击返回
d.press("back")
1.7左右滑屏
d.swipe_ext("left")
d.swipe_ext("right")
案例:实现屏幕九宫格解锁
import uiautomator2 as u2
d = u2.connect_wifi("192.168.101.65")
# 点亮屏幕并解锁
d.unlock()
# 获取当前屏幕状态
print(d.info.get("screenOn"))
# 滑动解锁
# duration为延时,0。2秒
d.swipe_points(points = [
        (0.23, 0.51),
        (0.506, 0.506),
        (0.77, 0.507),
        (0.504, 0.631),
        (0.232, 0.755),
        (0.5, 0.754),
        (0.772, 0.754)
],duration = 0.2)
# 锁屏
d.screen_off()

上一篇 下一篇

猜你喜欢

热点阅读