Uiautomator 2.0 - 实战

1  Android Studio -> Create project "uiautomator2demo"

2  cd uiautomator2demo

    cp ../libs ./

    选中libs/*.jar -> Add library -> 选择module -> app 

 

   则在 app/build.gradle 中

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "com.autotest.uiautomator2demo"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        // add testInstrumentationRunner
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'
    // 选中 libs/*jar , 右击 -> Add as Lib -> 选择Module -> app ,则自动生成下面的compile files
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/espresso-contrib-2.2-release-no-dep.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/espresso-core-2.2-release-no-dep.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/espresso-idling-resource-2.2-release-no-dep.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/espresso-intents-2.2-release-no-dep.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/espresso-web-2.2-release-no-dep.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/exposed-instrumentation-api-publish-0.3-release-no-dep.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/hamcrest-core-1.3.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/hamcrest-integration-1.3.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/hamcrest-library-1.3.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/javawriter-2.1.1.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/javax.annotation-api-1.2.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/javax.inject-1.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/jsr305-2.0.1.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/junit-4.12.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/rules-0.3-release-no-dep.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/runner-0.3-release-no-dep.jar')
    compile files('~/AndroidStudioProjects/uiautomator2demo/libs/uiautomator-v18-2.1.1-release-no-dep.jar')
}

  

posted @ 2017-01-12 18:48  ZSR0401  阅读(512)  评论(0编辑  收藏  举报