This action will force synchronization from 胥胥/Adb-For-Test, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
#Adb-For-Test
通过adb命令
实现简单的点击、滑动、长按等效果,可通过比例定位元素、通过元素定位(需要Android版本高于4.0),用于Android Test
,拥有monkeyrunner的绝大部分功能
###2015.04.28
重构python版本
中的adbUitils模块,合并AppInfo
、Action
类直ADB
中
初始化方法:
adb = ADB() 或 adb = ADB("device_id")
重构的目的是增加python版本对多设备的支持,通过传入device_id,解决有多台设备连接USB时无法执行脚本的问题
Element
类中增加通过属性content-desc
定位元素的方法
###Robotium
Robotium
处理跨进程,需要修改部分代码,请参考Adb-For-Robotium
###为何写这么个东西?
###优点
uiautomator
命令,Android4.0以上,可通过界面元素进行定位,可获取界面内单个元素区域的坐标范围,以此截取图片(区别于截取整个屏幕)###缺点
###需要的环境
###如何使用
Adb-For-Test.jar
即可###简单例子
在TestDemo目录下分别有python、java的例子,使用的apk是ApiDemos.apk
这里使用python写一个截取桌面应用图标的例子:
#coding=utf-8
import os
from adbUtils.utils.adbUtils import ADB
from adbUtils.utils.imageUtils import ImageUtils
from adbUtils.utils.element import Element
#单个设备可不传入device_id
adb = ADB(“device_id”)
element = Element("device_id")
#获取图片区域
icon = element.getElementBoundsByClass("android.widget.TextView")[0]
image = ImageUtils()
#截取图片
image.screenShot().subImage(icon).writeToFile(os.getcwd(), "image")
#加载需要对比的目标图片
#load = image.loadImage(os.getcwd() + "\\image.png")
#print image.screenShot().subImage(icon).sameAs(load)
Sign in for post a comment
Comments ( 0 )