python+appium【第二章-adb命令的使用】

  • 显示当前运行的全部模拟器
adb devices
  • 安装应用程序
adb install 应用程序.apk包的地址  

adb install D:apkjisuanqi.apk 
  • 获取apk的主包名
1.先打开apk
2.windos输入 adb shell dumpsys windows | findstr mCurrentFocus
3.Mac 输入 adb shell dumpsys windos | grep mCurrentFocus
4.mCurrentFocus=Window{abd2ea8u0 com.android.calculator2/com.android.calculator2.Calculator}
5.com.android.calculator2 为主包名
6.com.android.calculator2/com.android.calculator2.Calculator 活动包名

  • 卸载包
adb uninstall apk 主包名

adb uninstall com.android.calculator2
  • 进入apk终端
adb shell
  • 不能进入adb shell 模式 可能是端口占用的问题
adb nodaemon server

Netstat -ano | findstr “5037
  • 上传文件至手机终端
首先我们查找一下需要上传的终端路径

比如我们上传到moveis文件夹

那我们去查找moveis

Adb shell find -name Movies



然后上传我们一个txt文件试一下

adb push 本地文件路径  app的存放路径

adb  push D:apkaby.txt /data/media/0/Movies

 

 

下载app内的文件,比如日志什么的,把路径对换一下,还可以重新定义文件名称

adb pull 手机文件路径  本机地址路径文件名

adb pull /data/media/0/Movies/baby.txt D:apkabys.txt

  • 自动打开apk文件
adb shell am start -n 活动包名

adb shell am start -n com.android.documentsui/com.android.documentsui.files.FilesActivity
  • 清除指定apk的缓存
adb shell pm clear 包名
adb shell pm clear com.android.documentsui
  • 查看某一个app进程的相关信息
adb shell ps ef | grep 包名

1. windows : adb shell "ps -ef | grep com.android.documentsui"

2. Mac : adb shell ps -ef | grep com.android.documentsui
  • 查看某一个app的内存占用
adb shell dumpsys meminfo 包名

adb shell dumpsys meminfo com.android.documentsui
  • 杀掉某个进程 先查找进行信息
adb shell "ps |grep com.android.documentsui"

然后 adb shell kill 端口号

adb shell kill 4181


  • 操作简单的计算器

Android KEYCODE键值对大全 : https://blog.csdn.net/midux/article/details/80064054

操作计算机实现加法运算

1+8=9

adb shell input keyevent KEYCODE_1

adb shell input keyevent KEYCODE_PLUS

adb shell input keyevent KEYCODE_8

adb shell input keyevent KEYCODE_EQUALS

后续会继续更新,敬请关注

 

 

欢迎转载 请注明原出处
https://www.cnblogs.com/yushengaqingzhijiao/p/15219961.html

 

 

原文地址:https://www.cnblogs.com/yushengaqingzhijiao/p/15219961.html