Uiautomator 配置

2016-08-05  本文已影响78人  极速魔法

Eclipse新建Java project->package->class

导入Junit, android.jar,uiautomator.jar (Properties->java build path)

package com.test;

import com.android.uiautomator.core.UiObject;  
import com.android.uiautomator.core.UiObjectNotFoundException;  
import com.android.uiautomator.core.UiScrollable;  
import com.android.uiautomator.core.UiSelector;  
import com.android.uiautomator.testrunner.UiAutomatorTestCase;  

public class TestUi extends  UiAutomatorTestCase {
     public void testDemo() throws UiObjectNotFoundException{
         /*
          *test case
          */
         getUiDevice().pressHome(); //按下home键
     }

}

cd D:\programes\Android_SDK\tools,执行android create uitest-project -n <name> -t id -p <path>
path :project的绝对路径
name:project name
id:android list target查看

执行结束生成build.xml,F5刷新项目,打开build.xml,default="help"改为
default="build",右键build.xml->run as->ant build,完成打包。
ant配置:Download->Binary Distributions下载xx.zip文件,解压缩。环境变量新增ANT_HOME,添加路径D:\programes\apache-ant-1.9.7,path中添加%ANT_HOME%\bin

F5刷新,bin下 XX.jar,
adb push D:\programes\eclipse\Uitest\bin\TestUi.jar /data/local/tmp
adb shell uiautomator runtest TestUi.jar -c com.test.TestUi
com.test.TestUi :com.test 是package name
TestUi:class name

上一篇下一篇

猜你喜欢

热点阅读