常用操作


 

备注:电脑安装uiautomator2和weditor后,要记得运行python -m uiautomator2 init,这样手机端会自动安装ATX端

1、录屏:

device = u2.connect()
now = str(datetime.datetime.now()).replace(":", "_")
r = device.screenrecord("Mp4/" + now + ".mp4")
r.stop()

2、截屏

device.screenshot("test.png")

3、模拟按键

切换到主页

device.press("home")

4、滑动(从y2位置滑动到y1)

device.swipe(x2, y2, x1, y1)

5、监控(注册“系统操作”名称,当出现“确定”文字时进行点击操作)

device.watcher("系统操作").when("确定").click()