- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Android自动化测试之Monkeyrunner常用操作编程
Android自动化测试之Monkeyrunner常用操作编程
这是本人总结和整理的,基于 Python实现的脚本。实现的功能有:
屏幕滑动解锁、滑屏、长按、单击控件(三种方式)、输入文本、唤
醒屏幕、单击菜单键、单击主页键、单击电源键熄灭屏幕、重启、输
出设备屏幕截图到指定文件里、输出结果到指定文件里、打印当前时
间。
1.滑动解锁实现
def unlock_screen(device):
for i in range(1,3):
device.drag(138,1176,366,373,0.1,10)
2.滑屏实现
device.drag((286,150),(286,410),0.1,10)
3.长按实现
方式 1
easy_device.touch(By.id(id/shutter_button_photo),MonkeyDevice.DOW
N)
MonkeyRunner.sleep(1)
easy_device.touch(By.id(id/shutter_button_photo),MonkeyDevice.UP)
方式 2
device.touch(button_x, button_y, MonkeyDevice.DOWN)
MonkeyRunner.sleep(1)
device.touch(button_x, button_y, MonkeyDevice.UP)
4.输入文本(不支持空格输入)
Cotent = 1234
device.type(Cotent )
5.唤醒屏幕
device.wake()
6.单击菜单键
device.press(KEYCODE_MENU,MonkeyDevice.DOWN_AND_U
P)
7.单击主页键
device.press(KEYCODE_HOME
,MonkeyDevice.DOWN_AND_UP)
8.单击电源键,熄灭屏幕
device.press(KEYCODE_POWER,MonkeyDevice.DOWN_AND_
UP)
9.重启设备
device.reboot()
10.单击控件操作
方式 1
device.touch(button_x,button_y, )
方式 2
easy_device.touch(By.id(id/dialpad_button),MonkeyDevice.DOW
N_AND_UP)
方式 3
import sys,time,datetime,os
from com.android.monkeyrunner import
MonkeyRunner,MonkeyDevice,MonkeyImage
from com.android.monkeyrunner.easy import EasyMonkeyDevice
from com.android.monkeyrunner.easy import By
from com.android.chimpchat.hierarchyviewer import
HierarchyViewer
from com.android.hierarchyviewerlib.models import ViewNode
def getChildView(device,parentId, *childSeq):
hierarchyViewer = device.getHierarchyViewer()
str_getchildview=hierarchyViewer.findViewById( + parentId
+)
for index in childSeq:
str_getchildview+=(.children[ + str(index) + ])
exec child_view= + str_getchildview
return child_view
deleteDialogBox_x = 0
deleteDialogBox_y = 314
def touchDeleteEnterButton(device,easy_device):
#******** Delete Select Enter Button ******
try:
#select enter button
hierarchy_viewer = device.getHierarchyViewer()
enter_button = getChildView(device,id/content, 0, 3, 0,2)
except:
print Error,delete can not find cancel or enter button!
else:
point =
hierarchy_viewer.getAbsoluteC
您可能关注的文档
- Absolute Objects and Counterexamples Jones-Geroch Dust, Torretti Constant Curvature, Tetrad.pdf
- Absolute palaeointensity of Oligocene (28-30 Ma) lava flows from the Kerguelen Archipelago.pdf
- Absolute polarimetry at RHIC.pdf
- Absolute Proper Motions of H2O Masers Away from the Galactic Plane Measured with VERA in th.pdf
- Absolute properties of the binary system BB Pegasi.pdf
- Absolute Rate, Evolving Luminosity function, and Evolving Jet Opening Angle Distribution fo.pdf
- Absolute resonance strengths in the 6,7Li(alpha,gamma)10,11B reactions.pdf
- Absolute S-velocity estimation from receiver functions.pdf
- Absolute tip--tilt determination with laser beacon.pdf
- Absolute Upper Bound on the 1-loop Corrected mass of $S_1$ in the NMSSM.pdf
- Android题整理.doc
- André Wendt Bounding the Minimal Completion Time Intro Splitting 2 parts Combining Classes.pdf
- Ang et al 2009 JFE high idiosyncratic volatility and low returns.pdf
- Angle and Time of Arrival Statistics for.pdf
- angle branch in woody plant.pdf
- Angle Dependence of Polarization Observables by Fragmentation of Deuterons to Pions.pdf
- Angle iron size.doc
- ANGLE STEEL BAR.pdf
- Angle-resolved photoemission spectroscopy of band tails in lightly doped cuprates.pdf
- Angle structures and normal surfaces.pdf
最近下载
- 第四单元我们的生活空间 单元教学课件 2025北师版数学三年级上册.pptx
- NB_T 20006.5-2021 压水堆核电厂用合金钢 第5部分:反应堆压力容器封头用锰-镍-钼钢锻件.docx VIP
- 肾衰竭并发症(急性左心衰竭)的临床表现、处理与护理.pptx VIP
- 双诺希胶囊2定稿).ppt VIP
- 【低空经济】无人机防反制系统设计方案.pdf
- 2025年甾体激素原料药行业分析报告及未来五到十年行业发展趋势报告.docx
- 《中医经络面部美容》课件.ppt VIP
- 2025智算中心行业研究报告.pdf VIP
- (2025秋新版)人教版三年级数学上册《观察物体》PPT课件.pptx VIP
- 油料配送操作规程.docx VIP
文档评论(0)