111testing

史上最全的MonkeyRunner自动化测试从入门到精通(1)

2018-04-16 03:14  清风软件测试  阅读(636)  评论(0编辑  收藏  举报

原文地址https://zhuanlan.zhihu.com/p/26043620

MonkeyRunner使用

#-*- coding:utf-8 –*-
from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
#连接设备
device=MonkeyRunner.waitForConnection(3,"172.10.10.124:5555")
#启动App
device.startActivity("包名/类名")
#暂停两秒
MonkeyRunner.sleep(2)
#点击搜索框
device.touch(100,100,"DOWN_AND_UP")
#输入查询词
device.type(\'test\')
#点击回车键
device.press(\'KEYCODE_ENTER\',\'DOWN_AND_UP\')
#点击搜索按钮
device.touch(400,100,"DOWN_AND_UP")
#截图
image=device.takeSnapshot()
image.writeToFile(\'./test.png\',\'png\')
device.touch(300,100,"DOWN_AND_UP")
#弹出框
MonkeyRunner.alert(\'test over\',\'This is title\',\'OK\')

备注:
1坐标值可通过 sdk自带的uiautomatorviewer获取
2运行方式
 在tool目录下执行monkeyrunner file.py

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-12-02
  • 2021-11-20
  • 2021-11-20
  • 2022-02-16
  • 2021-04-16
  • 2022-12-23
猜你喜欢
  • 2021-11-20
  • 2021-06-09
  • 2021-12-05
  • 2021-11-20
  • 2021-12-06
  • 2022-01-13
  • 2022-02-14
相关资源
相似解决方案