使用android模拟事件,python完成自动化测试
2015-06-17 21:35
537 查看
基于以下几个原理:
1.可以通过adb向android手机发送模拟事件
比如,adb shell input text hello world
这是调用android键盘,输入hello world。
比如,adb shell input keyevent 19
这是调用android键盘的down键。
adb shell input tap 点击
adb shell input 滑动
2.可以通过adb启动某个app内的某个activity
比如,adb shell am start -n PackageName/ActivityName
这是调用android的ams,启动PackageName中的ActivityName。
3.python脚本可以将这些调用这些adb命令,也可以读写文件。
通过写一个python脚本,在脚本中调用adb命令,以及读写文件。当然,首先要在机器上按照python,如同安装php。
如果读写excel文件,还需要借助一些module,这正式python的长处。
1.可以通过adb向android手机发送模拟事件
比如,adb shell input text hello world
这是调用android键盘,输入hello world。
比如,adb shell input keyevent 19
这是调用android键盘的down键。
adb shell input tap 点击
adb shell input 滑动
2.可以通过adb启动某个app内的某个activity
比如,adb shell am start -n PackageName/ActivityName
这是调用android的ams,启动PackageName中的ActivityName。
3.python脚本可以将这些调用这些adb命令,也可以读写文件。
通过写一个python脚本,在脚本中调用adb命令,以及读写文件。当然,首先要在机器上按照python,如同安装php。
如果读写excel文件,还需要借助一些module,这正式python的长处。
相关文章推荐
- python学习笔记
- Python 装饰器
- Leetcode—Contains Duplicate II—Python
- Leetcode—Contains Duplicate—Python的三种写法
- 用Python提取XML里的内容,存到Excel中
- 机器学习算法与Python实践之(七)逻辑回归(Logistic Regression)
- Django1.8+Python3.4+Mysql5.5
- Python正则表达式操作指南
- [python]Python中变量的作用域(variable scope)
- ArcGIS Python 批量定义投影
- Python 字符串操作
- Python - 装饰器使用过程中的误区
- Python - 装饰器使用过程中的误区
- [python]Python中:self和__init__的含义,以及为何要有self和__init__
- python爬虫 爬取知乎用户的用户信息
- python调用java
- python greenlet背景介绍与实现机制
- 八皇后问题python实现
- 用Python写单向链表和双向链表
- 呵呵!手把手带你在 IIS 上运行 Python(转)