当前位置:网站首页>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
测试精讲视频
如果你觉的文章读的不过瘾,可以查看详细的视频教程。
学习路线如下




边栏推荐
- Concurrency-02-visibility, atomicity, orderliness, volatile, CAS, atomic class, unsafe
- Introduction, use and principle of synchronized
- 视觉上位系统设计开发(halcon-winform)-2.全局变量设计
- UnityShader——MaterialCapture材质捕捉效果 (翡翠斧头)
- Baidu AI Cloud helps Shizuishan upgrade the smart health care model of "Internet + elderly care services"
- Summary of JVM knowledge points
- Get the executable path through the process PID (queryfullprocessimagename)
- Unity function - unity offline document download and use
- Visual upper system design and development (Halcon WinForm) -4 Communication management
- Kubernetes - yaml file interpretation
猜你喜欢

秒杀系统3-商品列表和商品详情

VS2017通过IP调试驱动(双机调试)

Chapter 04_ Logical architecture

Introduction, use and principle of synchronized

秒杀系统2-Redis解决分布式Session问题

Basic SQL tutorial

CString getbuffer and releasebuffer instructions

How are integer and floating-point types stored in memory

秒殺系統3-商品列錶和商品詳情

Vs2017 is driven by IP debugging (dual machine debugging)
随机推荐
Creation and destruction of function stack frames
视觉上位系统设计开发(halcon-winform)
VC下Unicode和ANSI互转,CStringW和std::string互转
Using Tengine to solve the session problem of load balancing
What is machine reading comprehension? What are the applications? Finally someone made it clear
Jvm-04-runtime data area heap, method area
Use of Tex editor
Kubernetes - YAML文件解读
使用AUR下载并安装常用程序
Halcon与Winform学习第一节
Backtracking method to solve batch job scheduling problem
Leasing cases of the implementation of the new regulations on the rental of jointly owned houses in Beijing
Using notepad++ to build an arbitrary language development environment
SQL server installation location cannot be changed
Idea does not specify an output path for the module
[combinatorial mathematics] binomial theorem and combinatorial identity (binomial theorem | three combinatorial identities | recursive formula 1 | recursive formula 2 | recursive formula 3 Pascal / Ya
Introduction, use and principle of synchronized
驱动与应用程序通信
Enable multi-threaded download of chrome and edge browsers
C language brush questions ~leetcode and simple questions of niuke.com