Necessary skills for mobile testing: adb commands and packet capture

Mobile testing

It refers to the testing of mobile applications, that is, the degree to which the characteristics of entities meet the requirements, and a testing environment needs to be built before testing.

1 Mobile terminal automation environment construction

1.1 java installation

java JDK

Install jdk-8u181-windows-x64.exe

Configure environment variables:

JAVA_HOME:D:\developer tools\Java\jdk1.8.0_181

Configuration path: %JAVA_HOME%\bin

%JAVA_HOME%\jre\bin

Verification: terminal input: java -verison
insert image description here

1.2 Android SDK installation

UnzipAndroid-sdk.zip

Configure the environment variable ANDROID_HOME: D:\android-sdk-windows

Configure path:

%ANDROID_HOME%\platform-tools

%ANDROID_HOME%\tools

verify

Terminal input:
insert image description here

Install a phone emulator

Recommend Night Simulator

startup problem

Nox_adb.exe in the bin directory of the Yeshen Simulator needs to be consistent with the version of adb.exe in the SDK.
Copy adb.exe under SDKplatform-tools to the Yeshen bin directory and change the name – nox_adb.exe can be replaced

start method

1 Start the Yeshen emulator, enter adb connect 127.0.0.1:62001 in the terminal

Ways of identifying
insert image description here

2 ADB Android Debug Bridge

2.1 adb concept

adb concept

The full name of ADB is Android Debug Bridge, which is a debugging tool

adb is a command-line tool with C/S architecture, which consists of three parts. ADB is a bridge connecting mobile phones and computers. As long as this bridge is established, you can control your mobile phone through the computer.

2.2 adb working principle

adb consists of three parts:

Client side: run on the PC side, you can install, uninstall and debug Android applications through the adb command;

Daemon: Daemon process, running on the debugging device, mobile phone or emulator, used to receive and execute adb commands;

Server side: runs on the PC side, connects the client to the adb background process on the Android device, and is responsible for managing the communication between the client and the daemon.

2.3 adb common commands

Package name (package): the package of each app is a unique interface name (activity): the link in the web page

2.3.1 Get package name and interface name command

Application scenario: In automated testing, you need to know the package name and activity of the app, and obtain it through commands. Steps to use: Start the application under test and enter the command

Command format:

adb shell dumpsys activity|findstr Focused

 Example: query xxxxapp
insert image description here

2.3.2 adb file transfer command

Application scenarios: sending files to mobile phones, pulling files from mobile phones

Command format for sending files to the mobile phone:
adb push file path of the computer folder path of the mobile phone

 Example: Send the apk under the d disk to the sdcard directory of the mobile phone
insert image description here
Pull the file from the mobile phone Command line format:
adb pull mobile terminal path PC terminal folder
insert image description here

2.3.3 Get app startup time

Application scenario: Need to test the startup speed of the application

Command format:

adb shell am start -W 包名/启动名

insert image description here

ThisTime :该界⾯ ( activity ) 启动耗时(毫秒)
TotalTime :应⽤⾃身启动耗时 = ThisTime + 应⽤ application 等资源启动时间(毫秒)
WaitTime :系统启动应⽤耗时 = TotalTime + 系统资源启动时间(毫秒)

2.3.4 Get phone log command

Application scenario: Bug log information is sent to the development, which is convenient for development to locate problems

Steps for usage:

Start the application - Execute the location where the bug occurred - Use the command - Get the log information

command format

adb logcat

common commands

adb logcat|findstr com.xxxxx > E:/apk/logcat.txt

first step:

insert image description here
Step two:

insert image description here

2.3.5 adb other related commands
insert image description here

3 Mobile terminal capture

Mobile phone packet capture application scenarios:

Analyze the data through mobile phone packet capture to determine whether the bug is in the foreground or in the background

Use the fiddler tool to capture packets on the emulator

3.1 PC-side fiddler configuration

Configure fiddler to allow listening to https (fiddler only grabs http format by default)

Configure fiddler to allow remote connections
insert image description here

insert image description here
3.2 Configure parameters on the mobile terminal 

手机和电脑连接同一个网络
手机系统设置-无线网-点击高级,代理选择手动,主机名就是fiddler的电脑ip地址,端口号,就是
fiddler的端口号,与浏览器中ip:端口号保持一致,点击确定即可 打开手机浏览器 安装fiddler    证书IP:8888
重启后查看

Manually enter the IP address and port number on the mobile terminal
insert image description here 

Enter the IP: port in the browser, for example: 192.00.211:8888, and jump to the fiddler download page (as shown in the figure)
insert image description hereSettings > More Settings > Security > Credentials below (install from SD card)
insert image description here 

ios 13 new steps

Install fiddler certificate jump
insert image description here

Open Settings-General-About This Machine-Certificate Trust Settings, and turn on the DO_NOT_TRUST_FiddlerRoot switch.

insert image description here

Enter 'xx education'
insert image description here

Guess you like

Origin blog.csdn.net/nhb687095/article/details/131700937