0
点赞
收藏
分享

微信扫一扫

移动端自动化测试appium(1)--测试常用adb命令


开始学习移动端自动化测试,记些笔记。

先复习下测试中常用的adb命令(之后会用到),作为备忘录。

后续会持续更新appium系列文章。

移动端自动化测试appium(1)--测试常用adb命令_软件测试


常用adb命令

  • 获取已连接设备
adb devices
  • 获取app入口
adb logcat |findstr -i displayed
  • 安装apk
adb install 路径\包名.apk
  • 卸载
adb uninstall 包名
  • 关闭adb后台进程
adb kill-server
  • 启动adb
adb start-server
  • 让Android脱离USB线的TCP连接方式
adb tcpip
  • 连接开启了TCP连接方式的手机
adb connect
  • 收集日志数据,耗电量、内存等
adb bugreport

adb shell

adb shell 本身是一个Linux的shell  可以调用Android内置命令

  • 获得app各种信息,内存 cpu等
adb shell dumpsys XX
  • activity管理
adb shell am XX
  • 启动应用
adb shell am start -W -n 包名/活动页 -S (-S 先杀再起)
  • 杀掉应用
adb shell am force-stop 包名
  • 清除应用数据
adb shell pm clear 包名

遇到报错:does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package

解决办法:开发者选项里开启‘OEM解锁’、‘禁止权限监控’两个选项

  • 进程管理
adb shell ps XX
  • 健壮性测试
adb shell monkey

Android 性能统计 dumpsys

  • 获取当前activity
adb shell dumpsys activity top
  • 获取activities的记录,可以获取到appium依赖的原始activity
adb shell dumpsys activity activities
  • 获取特定包的基本信息
adb shell dumpsys package 包名
  • 获取系统通知
adb shell dumpsys notification
  • 获取特定包的内存信息
adb shell dumpsys meminfo 包名
  • 获取cpu信息
adb shell dumpsys cpuinfo
  • 获取gpu绘制分析
adb shell dumpsys gfxinfo 包名

uiautomator

  • 运行自动化测试用例
adb shell uiautomator runtest...
  • 获取界面信息
adb shell uiautomator dump

adb shell "uiautomator dump && cat /sdcard/window_dump.xml"

input命令

  • 输入文本
adb shell input text 文本
  • 输入键盘按键
adb shell input keyevent ‘keycode’
  • 点击坐标
adb shell input tap x y
  • 滑动
adb shell input swipe x1 y1 x2 y2

移动端自动化测试appium(1)--测试常用adb命令_包名_02

下方学习安排上


举报

相关推荐

0 条评论