http://automationtesting.sinaapp.com/blog/m_uiautomator
python模块介绍-uiautomator:Android自动化测试工具uiautomator
简介
- uiautomator适用于native的Android应用,但是无法处理web。
- 应用类型的基本概念参见: hybrid app
- 模块: uiautomator
- 目的: Python Wrapper for Android UiAutomator? test tool
- 月下载量:4k左右
- 地址:uiautomator
安装
- 安装uiautomator:
]#pip install uiautomator
Downloading/unpacking uiautomator
Downloading uiautomator-0.1.32.tar.gz (513kB): 513kB downloaded
Running setup.py (path:/tmp/pip_build_root/uiautomator/setup.py) egg_info for package uiautomator
Downloading/unpacking urllib3>=1.7.1 (from uiautomator)
Downloading urllib3-1.9.tar.gz (91kB): 91kB downloaded
Running setup.py (path:/tmp/pip_build_root/urllib3/setup.py) egg_info for package urllib3
Installing collected packages: uiautomator, urllib3
Running setup.py install for uiautomator
Running setup.py install for urllib3
Successfully installed uiautomator urllib3
Cleaning up...
- 到android-uiautomator-jsonrpcserver 下载最新的android-uiautomator-jsonrpcserver的jar文件。
# adb push bundle.jar /data/local/tmp/
# adb push uiautomator-stub.jar /data/local/tmp/
# adb shell uiautomator runtest bundle.jar uiautomator-stub.jar -c com.github.uiautomatorstub.Stub # 此步骤注意手机要通过USB连接到电脑,并允许调试和连接。
# adb forward tcp:9008 tcp:9008
# curl -d '{"jsonrpc":"2.0","method":"deviceInfo","id":1}' localhost:9008/jsonrpc/0 # 检查结果
{"jsonrpc":"2.0","id":1,"result":{"currentPackageName":"android","displayHeight":1280,"displayRotation":0,"displaySizeDpX":0,"displaySizeDpY":0,"displayWidth":720,"productName":"falcon","sdkInt":17,"naturalOrientation":true}}
执行python脚本:
from uiautomator import device as d
d(text="Settings").click()
注意:ubuntu中如果报:libstdc++.so.6,adb命令无法执行,需要执行apt-get install lib32stdc++6 lib32z1 lib32z1-dev
本文地址
- http://automationtesting.sinaapp.com/blog/m_uiautomator
- 本站地址:python自动化测试http://automationtesting.sinaapp.com 联系方式 飞信 372818219 飞信软件测试自动化测试及python群87531018 python开发自动化测试qq群113938272和开发测试qq群6089740 微博http://weibo.com/cizhenshi
- 关于评论:禁止非登录用户评论,可以使用用户名test密码test登录后评论,评论请尽可能留下联系方式,多谢!