Java自动化测试(adb常用命令 32)
adb
adb「Android Bebug Bridge」是用来连接安卓和PC的桥梁
常用操作:
帮助命令
1 | adb help |
检测连接到电脑的安卓设备
1 | adb devices |
从手机上拉取信息到电脑上
1 | adb pull <手机路径> <本地路径> |
从电脑上提交信息到手机上
路径不能有中文和特殊字符
1 | adb push <本地路径> <手机路径> |
安装软件
1 | adb install <本地软件路径> |
卸载软件
1 | adb uninstall <包名> |
登录设备进入shell
1 | adb shell |
终止adb服务
1 | adb kill-server |
启动adb服务
1 | adb start-server |
启动App
1 | adb shell am start -n <包名>/<入口> |
清除应用数据和缓存
1 | adb shell pm clear <包名> |
坐标点击
1 | adb shell input tap x坐标 y坐标 |
列出所有包名
1 | adb shell pm list packages |
打印日志
1 | adb logcat |
截图
1 | adb shell screencap -p /sdcard/Pictures/Screenshots/a.png |
appium打印内容解析(了解)
启动Appium的欢迎信息
1 | [Appium] Welcome to Appium v1.17.1 |
使用环境变量中配置的adb.exe
1 | [ADB] Found 1 'build-tools' folders under '/Users/zhongxin/Library/Android/sdk' (newest first): |
连接设备,并检测设备API版本号
1 | [ADB] Using 'adb' from '/Users/zhongxin/Library/Android/sdk/platform-tools/adb' |
等待设备连接
1 | [ADB] Running '/Users/zhongxin/Library/Android/sdk/platform-tools/adb -P 5037 -s 127.0.0.1\:62001 wait-for-device' |
检测Appium Setting安装状态
1 | [ADB] Running '/Users/zhongxin/Library/Android/sdk/platform-tools/adb -P 5037 -s 127.0.0.1\:62001 shell dumpsys package io.appium.settings' |
端口转发Appium Server端口8200连接到设备部中UiAutomator2 Server 6790
1 | [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8200 |
检测uiautomator2.server\uiautomator2.server.test安装状态
1 | [ADB] Getting install status for io.appium.uiautomator2.server |
验证uiautomator2.server\uiautomator2.server.test证书
1 | [ADB] Checking app cert for /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.5.5.apk |
检测柠檬班App安装状态
1 | [ADB] Getting install status for com.lemon.lemonban |
强制关闭和清空柠檬班app的缓存
1 | [ADB] Running '/Users/zhongxin/Library/Android/sdk/platform-tools/adb -P 5037 -s 127.0.0.1\:62001 shell am force-stop com.lemon.lemonban' |
启动柠檬班App
1 | [ADB] Running '/Users/zhongxin/Library/Android/sdk/platform-tools/adb -P 5037 -s 127.0.0.1\:62001 shell am start -W -n com.lemon.lemonban/com.lemon.lemonban.activity.WelcomeActivity -S' |