Basic use of Android automated testing tool Monkey

1. First install adb

Address: http://www.downza.cn/soft/219906.html
install to D drive, during the installation process, be careful not to install the whole family bucket.
Insert picture description here
Find this compressed package:
Insert picture description here
unzip it to the current folder:
Insert picture description here

2. Write the address of adb into the environment variable of the system

Insert picture description here
The D:\adb here depends on the individual, as long as your folder is opened with the following four files.
Insert picture description here

After completing this step, open cmd, enter the command adb, and display the version number, indicating that the installation is successful.
Insert picture description here

3. Get the device number (leave the phone in developer mode and enable USB debugging)

If you download version 1.0.26 as described in step 2 above, you may not be able to successfully obtain the device number under win10.
Update the version to solve the problem, address: https://adbshell.com/downloads , replace the three files in the compressed package with the three files with the same name in D:/adb
Insert picture description here

cmd try again, the version becomes 1.0.41:
Insert picture description here

This version can successfully obtain the device number.
Insert picture description here

Four. Start using

cmd input command: adb shell pm list packages to view the package names installed in the phone
Insert picture description here

Enter the command:
adb shell monkey -p XXXXXXXXXX --pct-touch 20 --pct-motion 20 --pct-trackball 20 --pct-appswitch 5 --pct-nav 5 --pct-majornav 10 --pct-anyevent 20 --ignore-crashes --ignore-timeouts --ignore-security-exceptions -v 10000 >F:/log/monkeylog2020.txt
can run automatically. Note that XXXXXXXXXX here is the package name, just follow the picture above. Just pick one.

Here, the command line will perform automated operations while running on the phone, and at the same time generate logs in F:/log/monkeylog2020.txt
Insert picture description here
Insert picture description here

Five. Simple analysis log

Monkey runs very fast, mainly for us to troubleshoot abnormalities and crashes
. Search for keywords in the txt log:
1.ANR: represents the program is not responding
2.crash: represents the crash
3.Exception: represents other problems

If you find the follow-up processing steps of the above event:
1. Find out where the error is in the monkey
2. Check some event actions in the monkey before the error, and perform the action manually
3. If the above steps cannot be found, you can use the previous Execute the executed monkey command again, paying attention to the same seed value

6. Wireless connection

1. The device number must be obtained when
Insert picture description here
USB is connected . 2. Enter the command: adb tcpip 5555, and then unplug the USB cable
Insert picture description here
3. Find the IP address of the phone
Insert picture description here

4. Enter the command: adb connect 192.168.1.6:5555, the connection is successful
Insert picture description here

OK, isn’t that all right, what you want is this effect!

Guess you like

Origin blog.csdn.net/qq_38175040/article/details/107611733