注意点:夜神模拟器的bin目录要加入path环境变量。
adb devices 查看设备连接列表
nox_adb devices -l 查看连接的设备
adb -s 1c0113fd shell dumpsys window | findstr mCurrentFocus 查看某台设备当前打开App的"appPackage"和"appActivity"。
appium连接模拟器的配置:
desired = {
"platformName": "Android",
"platformVersion": "9",
"deviceName": "1c0113fd",
"appPackage": "com.miui.home",
"appActivity": "com.miui.home.launcher.Launcher",
"automationName": "Appium",
"autoAcceptAlerts": True,
"noReset": True,
"unicodeKeyboard": True,
"resetKeyboard": True
}
设备号获取:adb devices
platformVersion获取:adb -s 设备号 shell getprop ro.build.version.release
deviceName获取:nox_adb devices -l
appPackage和appActivity获取:adb -s 设备号 shell dumpsys window | findstr mCurrentFocus
desired_caps = {
"platformName": "Android", # 操作系统
"deviceName": "emulator-5554", # 设备 ID
"platformVersion": "6.0.1", # 设备版本号
"appPackage": "com.tencent.mm", # app 包名
"appActivity": "com.tencent.mm.ui.LauncherUI", # app 启动时主 Activity
'noReset': True, # 是否保留 session 信息,可以避免重新登录
'unicodeKeyboard': True, # 使用 unicodeKeyboard 的编码方式来发送字符串
'resetKeyboard': True # 将键盘给隐藏起来
}
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)