基础环境
- JDK安装
- SDK安装
- node.js安装
- cmder安装(所有cmd命令均在该cmd下执行)
JDK 安装
a.环境变量新建:
1. JAVA_HOME
xx\Java\jdk1.8.0_151(安装路径)
2. CLASSPATH
.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
3. JRE_HOME
xx\Java\jre(安装路径)
b. 编辑Path变量:
%JAVA_HOME%\bin
%JRE_HOME%\bin
c. 测试安装
cmd -> java
SDK
# 关闭Studio
a. 新建环境变量
ANDROID_HOME
xxx\SDK SDK安装目录
b. 新建环境变量
ANDROID_SDK_HOME
xxx\AVD 模拟器安装路径
mv c:\\Users\\xxx\.android android_backup
c. 编辑系统变量Path
%ANDROID_HOME%\platform-tools
c. 测试安装
cmd -> adb
重启Android Studio -> 创建模拟器 -> 查看模拟器安装的路径
node.js 安装
a. npm配置
npm config set registry https://mirrors.huaweicloud.com/repository/npm/
npm config set registry https://registry.npm.taobao.org/
mkdir node_global
npm config set prefix "xx\nodejs\node_global"
mkdir node_cache
npm config set cache "xx\nodejs\node_cache"
b. 测试安装
cmd->npm -v
Appium 安装
- npm install -g appium
- npm install wd
- 测试安装: appium &
常见问题
adb 连接 Android Studio 模拟器
cannot resolve host
λ adb devices
List of devices attached
emulator-5554 device
λ adb connect emulator-5554
cannot resolve host 'emulator-5554' and port 5555: 不知道这样的主机。 (11001)
λ netstat -ano |grep 5554
TCP 127.0.0.1:5554 0.0.0.0:0 LISTENING 45812
TCP [::1]:5554 [::]:0 LISTENING 45812
λ adb connect 127.0.0.1
connected to 127.0.0.1:5555
uiautomatorviewer 重新打开,即可连接上模拟器
sample-code跑不起来
λ adb -s 127.0.0.1:5555 shell getprop ro.build.version.release
9
λ adb -s 127.0.0.1:5555 shell getprop ro.build.version.sdk
28
ANDROID_BASE_CAPS = {
'app': os.path.abspath('../../apps/ApiDemos-debug.apk'),
'automationName': 'UIAutomator2',
'platformName': 'Android',
'platformVersion': os.getenv('ANDROID_PLATFORM_VERSION') or '9.0',
'deviceName': os.getenv('ANDROID_DEVICE_VERSION') or '127.0.0.1:5555',
}
λ cd sample-code\python\test
λ pytest test_android_basic_interactions.py
========================================= test session starts =========================================
platform win32 -- Python 3.10.4, pytest-7.1.1, pluggy-1.0.0
rootdir: D:\xxx\sample-code\python\test
plugins: anyio-3.5.0
collected 2 items
test_android_basic_interactions.py .. [100%]
========================================== warnings summary ===========================================
|