美文网首页
Uiautomator 配置

Uiautomator 配置

作者: 极速魔法 | 来源:发表于2016-08-05 08:20 被阅读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

    相关文章

      网友评论

          本文标题:Uiautomator 配置

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