monkey
Is a program that runs on an emulator or device to generate a pseudo-random stream of user events
Install
Android SDK comes with
use
- Basic configuration options
adb shell monkey 100 # 对所有包随机操作 100 次
- Operational constraints
adb shell monkey -p com.xueqiu.android 100 # 指定对雪球app 随机操作 100 次
- Event type and frequency
- Debugging options
<!---->
- Event count
adb shell monkey -p com.xueqiu.android -s 20 80 # 时间种子,重复上一次的随机事件
adb shell monkey -p com.xueqiu.android -vv -s 20 80 # 详细日志
adb shell monkey -p com.xueqiu.android --throttle 500 100 # 时间延迟,使操作速度慢下来
adb shell monkey -p com.xueqiu.android --pct-touch 10 1000 # 事件百分比
Frequently used events
--pct-touch
: Touch events, such as clicks--pct-motion
: Action time, such as sliding--pct-trackball
: Track events, such as move + click, curve sliding--pct-majornav
: Main navigation events, such as back button, menu button
maxim
Improvements to monkey, including improved performance based on traversal rules
https://github.com/zhangzhao4444/Maxim
AppCrawler
https://github.com/seveniruby/AppCrawler
Environmental requirements
- java 8
- appium 1.8.x
installation method
- Direct download: https://pan.baidu.com/s/1dE0JDCH
- Compile from source
Execution parameters
- Capability setting: consistent with appium
- testcase: used to start the basic test case after the APP, can be understood as a precondition
- selectedList: traversal range setting
- triggerActions: Settings for triggering execution actions under specific conditions
execution parameter has a higher priority than the configuration file
Automation support--testcase
The complete form of testcase
- given: all prerequisites
- when: the behavior after the prerequisite is established
- then: assertion set
Short form of testcase
- xpath: corresponding to xpath in when
- action: corresponds to the action in when
Action support--action
- back: back
- backApp: Back to the current APP, the default is equivalent to the back behavior, can be customized
- monkey: random event
- xxx(): execute code
Thread.sleep(2000)
driver.swipe(0.9, 0.5, 0.1, 0.5)
- click: click
- longTap: Long press
Automatic traversal support
- selectedList: the range of elements that need to be traversed
- firstList: first clicked
- lastList: Last clicked
- tagLimitMax: The maximum number of clicks on elements of the same ancestor (same type)
- backButton: When all elements are clicked, the back control is positioned by default
- blackList: blacklist
- maxDepth: the maximum depth of traversal
trigger
triggerActions:
- Requires a specific number of trigger actions
- Usually used to handle bullet frames
- xpath: specify a specific button
- action: action
- times: the number of times the rule is used
Automatic traversal process
- Access to information
- Dump the interface of the current APP into an xml structure
- Get the elements to be traversed
- Traverse the range selectedList
- Filter blacklist, small space, blacklist of invisible controls
- Rearrange the order of controls firstList, lastList
- Skip has been clicked, and skip the control tagLimit that limits clicks
- Execute action according to matched rules
- Loop through the steps above
Logging
After execution, a log folder is generated to save all click screenshots
The log information is saved in the appcrawler.log file
Advanced usage
Generate the demo.yaml file: appcrawler --demo
Specify the configuration file: -c configuration file path
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。