The Monkeyscript of Android automated test cases

Source: Internet
Author: User

#文件名 Monkeyscript.mks
#功能: Using the Monkey script test app, this case is a test search function (enter keywords and then click the Search button)
#参考: http://blog.csdn.net/superloveboy/article/details/48469393
#http://yiweifen.com/html/news/waiyu/13792.html
#http://androidxref.com/5.1.1_r6/xref/development/cmds/monkey/src/com/android/commands/monkey/monkeysourcescript.java
#android. View.KeyEvent.java

#可以使用 android/sdk/tools/uiautomatorviewer.bat Get coordinate points

#执行方式 copy files to your phone such as/sdcard/00/monkeyscript.mks, run "adb shell monkey-f/sdcard/00/monkeyscript.mks 10" (not including quotes)
#-f is followed by the path to the script file, and the last number indicates the number of times the script was executed

#下面的这4行是固定值, without modification, to indicate the beginning of the script
Type = user
Count = 10
Speed = 1.0
Start Data >>

#启动activity
Launchactivity (com.iotlife.action,com.iotlife.action.activity.searchdetailactivity)
#等待ms时间
Userwait (200)

#DispatchPointer为点击某个坐标点, focus only on the 3,4,5 parameter
#第三个参数为事件类型 (0 is down,1 to up), 4th, 5 parameter is coordinate point x, y
#也可以用 Tap (1000,100) instead
Dispatchpointer (10,10,0,400,100,0,0,0,0,0,0,0);
Dispatchpointer (10,10,1,400,100,0,0,0,0,0,0,0);
Userwait (300)

#输入一个字符串
Dispatchstring (Test)
#输入一个回车键
Dispatchpress (Keycode_enter)
Userwait (300)


#DispatchPointer (10,10,0,1000,100,0,0,0,0,0,0,0);
#DispatchPointer (10,10,1,1000,100,0,0,0,0,0,0,0);
Userwait (300)

The Monkeyscript of Android automated test cases

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.