Appium+python automation (eighteen) - - Monkey event

Introduction to Operational Events

  The random event stream executed by Monkey contains 11 major events, namely touch event, gesture event, two-finger zoom event, track event, screen rotation event, basic navigation event, main navigation event, system button event, start Activity event, keyboard events, other types of events. Monkey uses these 11 major events to simulate the user's routine operations and conduct a stability test on the mobile app. Let's take a closer look at these 11 major events.

1. Touch events

A touch event refers to the operation of pressing and lifting somewhere on the screen, and its event percentage can be configured through the --pct-touch parameter. It can be seen from the log that Monkey executes the external output of this event. This event consists of a set of Touch (ACTION_DOWN) and Touch (ACTION_UP) events, and the actual operation seen on the mobile phone is similar to a click.

2. Gesture events

Gesture events refer to the operations of pressing, moving randomly, and lifting somewhere on the screen, that is, straight-line sliding operations. Its event percentage can be configured by the --pct-motion parameter.

This event is composed of an ACTION_DOWN event, a series of ACTION_MOVE events and an ACTION_UP event. The actual operation seen on the mobile phone is a straight-line sliding operation without turning.

3. Two-finger zoom event

The two-finger zoom event refers to the operation of pressing two places on the screen at the same time, moving at the same time, and finally lifting at the same time, that is, the zoom in and out gesture operation on the smart phone. Its event percentage can be configured by the --pct-pinchzoom parameter. From the external output log of Monkey executing this event, we can see:

The event starts with an ACTION_DOWN event and an ACTION_POINTER_DOWN event, which simulates two fingers clicking at the same time; the middle is a series of ACTION_MOVE events, that is, two fingers slide linearly on the screen at the same time; the end is an ACTION_POINTER_UP event and an ACTION_UP Event composition, that is, two fingers are released at the same time.

4. Track events

Track events consist of one or more random movements, sometimes followed by clicks. A long time ago, Android phones had a trackball, and this event is a simulated trackball operation. Most of the current mobile phones do not have a trackball, but the trackball event includes a curve sliding operation. If the program under test needs a curve sliding, this parameter can be selected. Its event percentage can be configured by the --pct-trackball parameter. From the external output log of Monkey executing this event, we can see:

This event is composed of a series of Trackball (ACTION_MOVE) events. Observe the operation on the mobile phone, that is, a series of curved sliding operations.

5. Screen rotation event

The screen rotation event is a hidden event, which is not recorded in the official Android documentation. It actually simulates the horizontal and vertical screen switching of Android phones. Its event percentage can be configured by the --pct-rotation parameter. From the external output log of Monkey executing this event, we can see: [Code] This event is composed of a rotation event, where degree represents the direction of rotation, clockwise rotation, 0 represents the direction of rotation of 90 degrees, and 1 represents the direction of rotation of 180 degrees Direction, 2 means the direction of rotation 270 degrees, 3 means the direction of rotation 360 degrees. During the execution process, you can see that the mobile phone screen is constantly switching between the horizontal and vertical screens.

6. Basic navigation events

The basic navigation event refers to the operation of clicking the up, down, left, and right buttons of the direction input device. Now there are few up, down, left, and right buttons on the mobile phone, and this kind of event is generally used less. Its event percentage can be configured by the --pct-nav parameter. From the external output log of Monkey executing this event, we can see:

The event is composed of a Key (ACTION_DOWN) and a Key (ACTION_UP), and the four direction keys of up, down, left, and right are clicked.

7. Main navigation events

The primary navigation event refers to the operation of clicking the "primary navigation" button. These buttons usually cause actions in the UI interface, such as the middle key of the keyboard, the back button, and the menu button. Its event percentage can be configured with the --pct-majornav parameter. From the external output log of Monkey executing this event, we can see: [Code] This event is composed of a Key (ACTION_DOWN) and a Key (ACTION_UP), and the clicked keys are the middle key and the menu key.

8. System button event

The system button event refers to the operation of clicking the button reserved by the system, such as clicking the Home button, the return button, and the volume adjustment button. Its event percentage can be configured through the --pct-syskeys parameter. From the external output log of Monkey executing this event, we can see: [Code] This event is composed of a Key (ACTION_DOWN) and a Key (ACTION_UP), and the clicks are the above-mentioned several system keys.

9. Start the Activity event

The start Activity event refers to the operation of starting an Activity on the mobile phone. At random time intervals, Monkey will execute a startActivity() method as a way to cover as much as possible all activities in the package under test. Its event percentage can be configured by the --pct-appswitch parameter. From the external output log of Monkey executing this event, we can see: [Code] This event is composed of a Switch operation. From the perspective of the mobile phone, the above operation actually opens a com.android of the application com.android.settings Activity interface of .settings.Settings.

10. Keyboard events

Keyboard events are mainly keyboard-related operations. For example, click on the input box, the keyboard pops up, click on an area outside the input box, and the keyboard retracts. Its event percentage can be configured by the --pct-flip parameter. You can see from the log that Monkey executes the event and outputs externally: [Code] As shown in the log, here is mainly the opening and closing operation of the keyboard.

11. Other types of events

Other types of events include all other events except the above-mentioned 10 events, such as key presses, buttons on other uncommonly used devices, etc. The event percentage can be configured through the --pct-anyevent parameter. From the external output log of Monkey executing this event, we can see: [Code] This event is composed of a Key (ACTION_DOWN) and a Key (ACTION_UP), and the clicked keys are other system keys, such as letter keys and number keys wait. Because mobile phones rarely have letter keys or number keys, this event is generally used less.


              [The following is the most complete software test engineer learning knowledge architecture system diagram in 2023 that I compiled]


1. From entry to mastery of Python programming

2. Interface automation project actual combat

3. Actual Combat of Web Automation Project


4. Actual Combat of App Automation Project

5. Resume of first-tier manufacturers


6. Test and develop DevOps system

7. Commonly used automated testing tools


Eight, JMeter performance test

9. Summary (little surprise at the end)

life is long so add oil. Every effort will not be let down, as long as you persevere, there will be rewards in the end. Cherish your time and pursue your dreams. Don't forget the original intention, forge ahead. Your future is in your hands!

Life is short, time is precious, we cannot predict what will happen in the future, but we can grasp the present moment. Cherish every day and work hard to make yourself stronger and better. Firm belief, persistent pursuit, success will eventually belong to you!

Only by constantly challenging yourself can you constantly surpass yourself. Persist in pursuing your dreams and move forward bravely, and you will find that the process of struggle is so beautiful and worthwhile. Believe in yourself, you can do it!

Guess you like

Origin blog.csdn.net/NHB456789/article/details/131850851