美文网首页
uiautomator基本步骤

uiautomator基本步骤

作者: Phoobobo | 来源:发表于2017-01-08 22:17 被阅读77次

1 新建工程

1)在eclipse新建Java Project.
2)配置:
1 进入工程properties->Java Build Path->Libraries->Add Library...->JUnit
2 Add External JARs,以android-23为例,选择sdk/platforms/android-23/android.jar和uiautormator.jar

2 测试代码

编写测试类继承UiAutomatorTestCase
编写测试方法throws UiObjectNotFoundException

3 编译

通过下面这条命令生成 build.xml
android create uitest-project -n MyFirstUIAutomator -t 1 -p workspace/MyFirstUIAutomator/
其中-t后面是平台版本,可以通过运行android list target查询,-p后面是工程路径
安装ant,在工程目录运行命令:
ant build

4 运行测试

adb push bin/MyFirstUIAutomator.jar /data/local/tmp/
其中后面的路径是默认路径
adb shell uiautomator runtest MyFirstUIAutomator.jar -c TestCase
-c后面是测试类的相对路径

相关文章

网友评论

      本文标题:uiautomator基本步骤

      本文链接:https://www.haomeiwen.com/subject/iikcbttx.html