appium + java auto test environment build

1. install: appium, 夜神模拟器,android-sdk

(1) Appium-windows-1.13.0.exe

(2) nox_setup_v7.0.3.1_full.exe

(3)android-sdk_r24.4.1-windows.zip (also need to config environment variable in u computer)

(4)JDK, eclipse

Android_SDK的安装

(1)把下载的文件包解压

(2)到解压的文件夹里,找到“SDK Manager.exe”

(3)双击“SDK Manager.exe”,打开SDK管理器(以下尽量必选,其余按需求选择)

a、安卓版本: 勾选自己测试使用手机的安卓版本和API版本的父节点和子节点

b、tools父节点下的以下三个子节点:Android SDK、Android SDK Platform-tools、Android SDK Build-tools

c、Extras父节点的以下子节点:Android Support Respository、Google USB Driver、Intel x86 Emulator Accelerator(HAXM installer)

(4)勾选完成,点击右下角的“install 14 packages”,其中14为动态数字,根据自己勾选项目数
(5)出现弹窗,点击右下角的“Accept License”,如果勾选没有问题,右下角的install按钮会允许点击。(无法点击,需要根据install上方的提示进行处理)

(6)点击install按钮后,弹窗消失,然后SDK Manager就会出现安装进度条,静等安装就可以了

(7)想删除已安装的内容,很简单,自己勾选对应项,然后点击右下角的"Delete 1 packages",数字1是动态的,你勾选了几个就显示几个

三、环境变量配置

1、新增ANDROID_HOME变量,值为SDK所在的目录,如E:androidsdkandroid-sdk-windows

2、编辑path变量,添加;%ANDROID_HOME% ools;%ANDROID_HOME%platform-tools

四、检测环境

1、cmd模式下输入adb命令,查看返回对应版本号( adb version)

2、手机成功连接电脑后,在cmd模式下输入adb devices命令,查看返回内容device前有一串字符

3、输入以上2个命令,提示不正确,那么请检查自己的环境,也可以选择把环境整体删除后重新配置,或者留言交流讨论一下

there is a conflict in D:\android-sdk-windows\platform-tools\adb.exe and D:\Program Files\Nox\bin\nox_adb.exe, u need to replace nox_adb.exe with adb.exe (change name to be nox_adb.exe).

3. appium inspector config (1. start NOX; 2. start Appium; 3. start Inspector Session; 4. set Desired Capabilities)

win+r

C:\Users\Administrator>adb devices
List of devices attached
127.0.0.1:62001 device

(sometimes, u need to execute adb connect 127.0.0.1:62001 command first, then execute adb devices)

4. D:\android-sdk-windows\build-tools\29.0.3>aapt dump badging D:\software\wechat_8.0.18_androidapksbox.apk
package: name='com.tencent.mm' versionCode='2060' versionName='8.0.18' compileSdkVersion='30' compileSdkVersionCodename='11'
install-location:'auto'
sdkVersion:'21'
targetSdkVersion:'30'

5. command

Microsoft Windows [版本 10.0.15063]
(c) 2017 Microsoft Corporation。保留所有权利。

C:\Users\Administrator>adb version
Android Debug Bridge version 1.0.41
Version 29.0.6-6198805
Installed as D:\android-sdk-windows\platform-tools\adb.exe

C:\Users\Administrator>java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

C:\Users\Administrator>mvn -version
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: D:\apache-maven-3.8.4
Java version: 1.8.0_121, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_121\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

C:\Users\Administrator>adb devices
List of devices attached
127.0.0.1:62001 device

6. desired capabilities

{
  "deviceName": "127.0.0.1:62001",
  "platformName": "Android",
  "appPackage": "com.tencent.mm",
  "appActivity": "com.tencent.mm.ui.LauncherUI",
  "noReset": true
}

7.  (1)inspector of NOX; (2)D:\android-sdk-windows\tools\uiautomatorviewer.bat(.bat是windows的批处理文件)

8. C:\Users\Administrator>adb shell dumpsys activity | find "mFocusedActivity"
  mFocusedActivity: ActivityRecord{6490bdc u0 com.tencent.mm/.plugin.account.ui.WelcomeActivity t14}

/* package name/class name(every page the of APP has their own class name) */

9. android debug bridge - adb

10. adb command

adb install D:\apk\QQ_818.apk

adb shell dumpsys activity | find "mFocusedActivity"

adb uninstall com.tencent.mobileqq

Success

adb kill-server

adb start-server

after restart, u need to connect adb devices again:

C:\Users\Administrator>adb devices
List of devices attached
127.0.0.1:62001 device


C:\Users\Administrator>adb kill-server

C:\Users\Administrator>adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully

C:\Users\Administrator>adb devices
List of devices attached


C:\Users\Administrator>adb connect 127.0.0.1:62001
connected to 127.0.0.1:62001

C:\Users\Administrator>adb devices
List of devices attached
127.0.0.1:62001 device

C:\Users\Administrator>adb shell am start -n com.tencent.mm/com.tencent.mm.ui.LauncherUI

/*start app  packageName/launcherUIName*/

C:\Users\Administrator>adb shell pm clear com.tencent.mm
Success  /*clear app data by package name*/

C:\Users\Administrator>adb shell input tap 643 420

/*打开设置 - 关于平板电脑 - 点击版本号5次 - 打开开发者模式,回到主页,在屏幕上方会显示xy坐标,可以通过坐标打开app, 还可以通过坐标点击按钮等*/

C:\Users\Administrator>adb shell pm list packages -3

C:\Users\Administrator>adb shell pm list packages -s

/*list all packages of system(do not uninstall) or third part*/

C:\Users\Administrator>adb logcat > D:\logcat
拒绝访问。

C:\Users\Administrator>adb logcat > D:\logcat\log20220711.txt
^C

打印日志

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值