toast prompt access to information and notes Monkey

Get toast

toast prompted scene: after the user enters a user name and password, prompt 'login successful', by locating previous methods could not get, you need Uiautomator2 to get

Installation Node.js (or node using authentication npm)


node-v8.11.3-x64.msi (windows) or node-v8.10.0.pkg (mac) installed

Installation CNPM (use authentication CNPM)


asl install -g cnpm --registry = https: //registry.npm.taobao.org

Download appium-uiautomator2-driver


cnpm install appium-uiautomator2-driver

Add prefix code


desired_caps['automationName'] = 'Uiautomator2'

Use driverWait way to find


find_toast DEF (Driver, Message, timeout =. 3):
  "" "
  # Message: message intended to be part of the acquired toast
  " ""
  Message = "// * [the contains (@Text, '" + + Message "')] "# manner containing targeting   Element = WebDriverWait (Driver, timeout, 0.1) .until (the lambda X: x.find_element (By.XPATH, Message))   return element.text


 

 

 


 

monkey environment

With the Android environment

What is Monkey

As the name suggests, Monkey is a monkey, Monkey test, like a monkey in front of a computer, chaotic keyboarding test. Monkeys do not understand anything, just know Luanqiao

To stress test a program on a device simulation program Monkey user touches the screen, the slide Trackball, operation keys and the like, how long will the program detects abnormality occurs

What to do Monkey

Monkey major stress test for Android automatically a stress test gadget, the main purpose is to test whether the app will Crash.

Monkey program introduced

  • Monkey Android system comes with the program, written in the Java language, storage path in the Android file system is: /system/framework/monkey.jar;

  • Monkey.jar program consists of a Shell script called "monkey" to start the execution, shell script storage path in the Android file system are: / system / bin / monkey;

  • Monkey command Start:

    • CMD can be performed by the PC window: adb shell monkey {+} command parameters to test Monkey

    • On Android PC adb shell into the system by performing monkey {+} command parameters to test Monkey

    • Monkey execute commands directly on Android machine or emulator may be mounted Android terminal emulator (Terminal Emulator for Android) on Android machine

Monkey output log

adb shell monkey -p cn.goapk.market 100> path /log.txt

Monkey Basic parameters introduced

  • -p <package name allowed list>

This parameter specifies one or more packets. After specifying the package, monkey would only allow the system to start the specified app. If you specify a list of packages, monkey would allow the system to start all app device.

Specifies a package: adb shell monkey -p cn.goapk.market 100

Specify multiple packages: adb shell monkey -p fishjoy.control.menu -p cn.goapk.market 100

100: 100 point corresponding to the operation, comprising actions and events, many operation (pressing, lifting, sliding, etc.) constitutes an event,

  • -v

Right foot level specified by the feedback information (log information level is the level of detail), a total of three sub-levels, respectively corresponding to the parameters as follows:

Level 0: adb shell monkey 100 // defaults -p cn.goapk.market -v, only a small amount of information to start prompt, complete and final test results, etc.

Level 1: adb shell monkey -p cn.goapk.market -v -v 100 // provide a more detailed log, including information about each event is sent to the Activity

Level 2: adb shell monkey -p cn.goapk.market -v -v -v 100 // most detailed logs, including the test checked / unchecked Activity Information

  • -s (random seed) reproducing Procedure

Specifies the pseudo-random number generator with a seed value right foot, if the same seed, the sequence of events generated by the two test Monkey is also the same. Example:

monkey Test 1: adb shell monkey -p cn.goapk.market -s 10 100

monkey Test 2: adb shell monkey -p cn.goapk.market -s 10 100

If a crash occurs app, available for use -s plus top seed value will be restored steps but may be due to network reasons, the effect is not the same as the implementation of such a picture can be loaded before you click out of the article, the second in test time, after clicking the picture, but the article does not load it.

  • --throttle <milliseconds>

Delay specified by a user operation right foot (i.e., events) between milliseconds; if this parameter is specified, Monkey will generate and transmit messages as fast as possible. Example: adb shell monkey -p cn.goapk.market --throttle 3000 100

An event consists of a number of actions,

Monkey Log Analysis


--pct-touch <percent>
to adjust the percentage of the touch event (the touch event is a down-up event, which occurs at a single location on the screen). --pct-motion <percent> adjusting operation percentage events (act on the screen by the event somewhere in a down event, a series of events and a pseudorandom up of events). --pct-trackball <percent> to adjust the percentage of track events (track events by one or more random movement composition, sometimes accompanied by clicks). --pct-pinchzoom <percent> scaling percentage of events --pct-nav <percent> adjustment percentage "substantially" navigation event (navigation event from the input device by the direction up / down / left / right composition). --pct-majornav <percent> percent "primary" navigation event adjusted (typically initiates the operation of these navigation event graphical interface, such as: backoff key, a menu key) -PCT-the syskeys <Percent> adjustment "System "Percent key events (these buttons are typically reserved for use by the system, such as Home, Back, Start Call, End Call , and volume control keys). --pct-appswitch <percent>




















Activity percentage of adjusted start. At random intervals in, it will perform a startActivity Monkey () call, the entire package Activity A method as the maximum degree of coverage. --pct-flip <percent> keyboard rollover event percentage --pct-anyevent <percent> The percentage adjustment of other types of events. It include all other types of events, such as: buttons, other less frequently used device button, and so on.





  • normal situation

If the test is successful Monkey execution is complete, the log of the last, will print out the number of the currently executing event and the time it takes; // Monkey finished completed behalf of the Executive

  • abnormal situation

After Monkey test error, the general analysis steps to see Monkey log (note that the first swith and exception information, etc.) \ 1 unresponsive problem: search "ANR" in the log . \ 2 crashes: in the log Search "Exception" (if null pointer appears, NullPointerException) is definitely a bug Monkey execute the interrupt, finally able to see the current number of executions in the log

monkey can only test crashes or not, can not test the business logic

Guess you like

Origin www.cnblogs.com/snailon/p/11242638.html