uiautomator2环境搭建

一、安装过程

1、安装JDK(自行百度,网上很多例子)

2、安装SDK(可以先不下载,通过android studio下载)

3、安装android studio

二、创建一个android工程

切换到android视图

在 androidTest下编写测试用例

三、配置gradle

 

 1、加入uiautomator2.0依赖

androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'

 2、配置maven镜像仓库

buildscript {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.2'
        
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/google' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

四、API文档

 https://developer.android.google.cn/reference/android/app/UiAutomation

https://blog.csdn.net/zhubaitian/article/details/40504827

原文地址:https://www.cnblogs.com/yaoqingzhuan/p/12554286.html