python 常用 uiautomator语法
来源:互联网 发布:域名查询腾讯 编辑:程序博客网 时间:2024/06/15 22:03
原文:http://www.bkjia.com/Pythonjc/1200927.html
1.获取设备信息
语法:d.info
返回值:
{ u'displayRotation': 0,
u'displaySizeDpY': 640,
u'displaySizeDpX': 360,
u'currentPackageName': u'com.android.launcher',
u'productName': u'takju',
u'displayWidth': 720,
u'sdkInt': 18,
u'displayHeight': 1184,
u'naturalOrientation': True
}返回值解释如下:
displayRotation 0 代表竖屏 1 代表横屏
currentPackageName 当前的Activity的Package名字
productName 当前设备名称
displayWidth 当前设备屏幕宽度 当 displayRotation 取值为 1 时,也就是说当前是横屏状态时,displayWidth 取值会和 displayHeight 互换
displayHeight 当前设备屏幕高度 当 displayRotation 取值为 1 时,也就是说当前是横屏状态时,displayHeight 取值会和 displayWidth 互换
sdkInt 当前SDK版本
naturalOrientation 当 displayRotation 取值为 1 时,也就是说当前是横屏状态时,取值为False,为竖屏状态时,取值为:True
2.系统常用操作
点亮或熄灭屏幕(Turn on/off screen)
# Turn on screen
d.screen.on()
# Turn off screen
d.screen.off()
检查屏幕状态,关闭OR点亮?
if d.screen == "on": # of d.screen != "off"
# do something in case of screen on
pass
if d.screen == "off": # of d.screen != "on"
# do something in case of screen off
pass
# home键
d.press.home()
# 返回
d.press.back()
# 返回
d.press("back")
3.与设备交互(单击、长按、滑动(手势密码)、拖拽)
# 单击屏幕坐标点
d.click(x, y)
# 长按屏幕坐标点
d.long_click(x, y)
# 在屏幕上滑动
# swipe from (sx, sy) to (ex, ey)
d.swipe(sx, sy, ex, ey)
# swipe from (sx, sy) to (ex, ey) with 10 steps
d.swipe(sx, sy, ex, ey, steps=10)
# 在屏幕上拖拽
# drag from (sx, sy) to (ex, ey)
d.drag(sx, sy, ex, ey)
# drag from (sx, sy) to (ex, ey) with 10 steps
d.drag(sx, sy, ex, ey, steps=10)
锁屏/解除锁屏
# freeze rotation
d.freeze_rotation() #锁屏
# un-freeze rotation
d.freeze_rotation(False) #解锁
# 截屏操作
d.screenshot("home.png")
# 打开通知或快速设置
# open notification, can not work until Android 4.3.
d.open.notification()
# open quick settings, can not work until Android 4.3.
d.open.quick_settings()
注意:(如果notification已经打开了,调用d.open.quick_settings()不会打开快速设置)
# 等待空闲或窗口更新(Wait for idle or window update)
# wait for current window to idle
d.wait.idle()
# wait until window update event occurs
d.wait.update()
- python 常用 uiautomator语法
- Python常用语法
- Python常用语法
- python 常用 语法 库函数
- Python常用简单语法
- python常用语法
- python常用语法
- python之常用语法技巧
- Python自动化测试常用语法
- python机器学习常用语法
- python scrapy xpath常用语法
- Python 常用语法函数整理
- Python语法备忘-常用函数
- python+uiautomator环境搭建
- Python-uiautomator使用说明文档
- Python--uiautomator特殊情况
- python uiautomator API
- Python-uiautomator使用说明文档
- Eclipse安装Python解释器pydev
- 算法,排序算法
- socket + vue + canvas实践,你画我猜(二)
- Android四大启动模式
- centos7 设置LANG后中文依然乱码
- python 常用 uiautomator语法
- 如何获取GPS状态
- DHTML技术综合演示---示例:表格排序
- c++ 继承
- CRC校验码的理解+CRC校验码算法代码
- unity5 资源提取工具
- 设计模式之工厂模式
- android中scrollview嵌套listview的问题
- AngularJS学习笔记--$resource的应用