每天一个安卓测试开发小知识之 (七)---常用的adb 命令第五期

每天一个安卓测试开发小知识之 (七)---常用的adb 命令第五期

hello,宝子们,最近没有更新是因为工作太忙了,刚结束完本年度答辩, 以后还会继续更新,如果有想了解的可以评论,你们的评论我都会看,笔心

上期介绍了如何通过adb命令输入文字,本期介绍如何通过adb 点击坐标

  • adb命令获取手机屏幕大小(分辨率)
  • adb命令点击坐标
  • adb命令按下物理按键
  • adb命令获取当前手机的旋转方向
  • adb命令获取当前手机的折叠状态【针对折叠屏手机】

1. 获取手机屏幕大小(分辨率)

bash 复制代码
adb shell wm size

屏幕分辨率 横 10802520

  • 扩展
  1. 查看 wm 命令帮助
bash 复制代码
adb shell wm help

2. 解锁屏幕【没有锁屏密码,屏幕已经点亮】

bash 复制代码
 adb shell wm dismiss-keyguard
  1. 方向锁定
bash 复制代码
adb shell wm user-rotation lock

不锁定方向

bash 复制代码
adb shell wm user-rotation free
  1. wm shell命令 4.1 获取帮助
bash 复制代码
adb  shell wm shell help

4.2 清除最近任务

adb shell wm shell recents clearAll

2. 点击坐标

bash 复制代码
adb shell input tap 500 1000

查看input命令帮助

bash 复制代码
adb shell input help

input 命令可执行的指令包括

  • tap <x> <y> (Default: touchscreen) 点击
  • swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen) 滑动
  • text <string> (Default: keyboard) 输入文字
  • keyevent [--longpress|--duration <duration to hold key down in ms>] [--doubletap] [--async] [--delay <duration between keycodes in ms>] <key code number or name> ... (Default: keyboard) 模拟按下和释放物理按键 比如 home adb shell input keyevent 3
bash 复制代码
# 数字键 0-9
adb shell input keyevent 7    # 0
adb shell input keyevent 8    # 1
adb shell input keyevent 9    # 2
adb shell input keyevent 10   # 3
adb shell input keyevent 11   # 4
adb shell input keyevent 12   # 5
adb shell input keyevent 13   # 6
adb shell input keyevent 14   # 7
adb shell input keyevent 15   # 8
adb shell input keyevent 16   # 9

# 字母键 A-Z
adb shell input keyevent 29   # A
adb shell input keyevent 30   # B
adb shell input keyevent 31   # C
# ... 以此类推

3. 获取当前手机的旋转方向

bash 复制代码
adb shell settings get system user_rotation

命令settings表示直接操作手机设置,手机里很多设置项都可以使用 get 获取对应的值 put 设置对应的值

4. 当前手机的折叠状态

bash 复制代码
 adb shell cmd device_state print-state

0 完全合上 3 完全打开 device_state 命令扩展

  • 查看帮助
bash 复制代码
adb shell cmd device_state

比如获取当前手机支持的状态

bash 复制代码
 adb shell cmd device_state print-states
bash 复制代码
adb shell cmd 

这个命令还有很多其他功能 我们后续继续分享 每天进步一点点!!!

相关推荐
weixin_4130632113 小时前
测试 focus stacking
opencv·测试·focus stacking
_OP_CHEN2 天前
【测试理论与实践】(四)测试用例篇(上):从概念到万能思路,解锁测试设计核心密码
运维·测试开发·测试用例·bug·压力测试·测试·网络测试
请为小H留灯4 天前
Windows 系统启用 Telnet 客户端:图文详细教程
网络·windows·测试·telnet
Apifox4 天前
Apifox 12 月更新| AI 生成用例同步生成测试数据、接口文档完整性检测、设计 SSE 流式接口、从 Git 仓库导入数据
前端·后端·测试
_OP_CHEN4 天前
【测试理论与实践】(三)测试BUG篇:从 BUG 本质到实战博弈,带你吃透软件测试的核心逻辑
运维·测试开发·产品运营·bug·压力测试·测试
以己之6 天前
初识测试(详细篇)
单元测试·压力测试·测试
零基础的修炼7 天前
[测开项目]问卷系统测试---测试用例
测试
0和1的舞者8 天前
《软件测试分类指南:8 大维度 + 核心要点梳理》
java·软件测试·单元测试·测试·黑盒测试·白盒测试·测试分类
WebInfra9 天前
Midscene v1.0 发布 - 视觉驱动,UI 自动化体验跃迁
javascript·人工智能·测试
雪球工程师团队9 天前
从人力推车到智能引擎:QA 智绘项目的测试用例自动生成术
ai编程·测试