当前位置:网站首页>App移动端测试【5】文件的写入、读取
App移动端测试【5】文件的写入、读取
2022-07-03 15:30:00 【Leo_Eagle】
文件的写入、读取;
adb命令的管理
1. 文件的操作
1.1 写入
将文件写入到手机中是常见的操作,写入的操作如下。
C:\Users\Leo>adb shell
[email protected]:/ # ls
….
sdcard
…..
C:\Users\Leo>adb push G:\demo.txt /sdcard
G:\demo.txt: 1 file pushed.
C:\Users\Leo>adb shell
[email protected]:/ # cd sdcard
[email protected]:/sdcard # ls
….
Demo.txt
…..
格式:在cmd中
Adb push pc端的文件 mobile端的目录
案例:
C:\Users\Leo>adb push G:\demo.txt /sdcard
1.2 读取
从手机中读取文件也属常见的操作,读取的操作案例如下。
先在sdcard创建1个huawei.txt
[email protected]:/sdcard # touch huawei.txt
[email protected]:/sdcard # ls
Huawei.txt
从手机端pull到本地pc端
C:\Users\Leo>adb pull /sdcard/huawei.txt G:\
adb: error: cannot create file/directory 'G:\': No such file or directory
C:\Users\Leo>adb pull /sdcard/huawei.txt G:\Demo
/sdcard/huawei.txt: 1 file pulled.
格式:adb pull 手机端的文件 pc端路径下
如:adb pull /sdcard/huawei.txt G:\Demo
注意:pull过程中,不能直接pull到某个磁盘下,必须到某个文件夹下(否则可能报错)。
adb: error: cannot create file/directory 'G:\': No such file or directory,
2. 屏幕截图
脚本执行过程中,可能会遇到错误,需要截取App(或屏幕)的错误截图,可对分析问题十分有帮助。
C:\Users\Leo>adb shell screencap /sdcard/yeshen.png
C:\Users\Leo>adb pull /sdcard/yeshen.png G:\Demo
/sdcard/yeshen.png: 1 file pulled. 1.8 MB/s (335838 bytes in 0.179s)
注意:图片后缀名不要是jpg。否则有问题
3. Adb启动与关闭
通过控制adb服务的启动,从而实现对手机的控制。
启动adb服务
C:\Users\Leo>adb start-server
关闭adb服务
C:\Users\Leo>adb kill-server
查看谁在使用5037端口
C:\Users\Leo>netstat -ano |findstr "5037"
TCP 127.0.0.1:5037 127.0.0.1:55182 TIME_WAIT 0
4. adbdevices.bat
如何实现adb服务的控制,可通过编写bat来实现。
先创建bat,内容如下:运行下可以看到一闪而过
adb devices
再编辑成如下这样,末尾加上pause,就会暂停住了。
adb devices
pause
如:
AdbConnect.bat
adb connect 127.0.0.1:62025
adb devices
pause
测试精讲视频
如果你觉的文章读的不过瘾,可以查看详细的视频教程。
学习路线如下




边栏推荐
- Custom annotation
- 基于SVN分支开发模式流程浅析
- 求字符串函数和长度不受限制的字符串函数的详解
- 使用AUR下载并安装常用程序
- 百度智能云助力石嘴山市升级“互联网+养老服务”智慧康养新模式
- Analysis of development mode process based on SVN branch
- Unityshader - materialcapture material capture effect (Emerald axe)
- QT common sentence notes
- "Seven weapons" in the "treasure chest" of machine learning: Zhou Zhihua leads the publication of the new book "machine learning theory guide"
- Halcon与Winform学习第二节
猜你喜欢

Seckill system 3- product list and product details

Leasing cases of the implementation of the new regulations on the rental of jointly owned houses in Beijing

GCC cannot find the library file after specifying the link library path

Seckill system 2 redis solves the problem of distributed session

mysql innodb 存储引擎的特性—行锁剖析

详解指针进阶2

Find mapping relationship

C language brush questions ~leetcode and simple questions of niuke.com

Reentrantlock usage and source code analysis

qt使用QZxing生成二维码
随机推荐
Find mapping relationship
Basic SQL tutorial
[daily training] 395 Longest substring with at least k repeated characters
leetcode_ Power of Four
socket.io搭建分布式Web推送服务器
Jvm-05-object, direct memory, string constant pool
The difference between RAR and zip files
Chapter 04_ Logical architecture
Tensorflow realizes verification code recognition (II)
Detailed pointer advanced 1
整形和浮点型是如何在内存中的存储
C语言刷题~Leetcode与牛客网简单题
找映射关系
通过进程PID获取可执行文件路径(QueryFullProcessImageName)
北京共有产权房出租新规实施的租赁案例
【云原生训练营】模块八 Kubernetes 生命周期管理和服务发现
Wechat payment -jsapi: code implementation (payment asynchronous callback, Chinese parameter solution)
Kubernetes - yaml file interpretation
Popular understanding of linear regression (II)
Digital image processing -- popular Canny edge detection