Monkeyrunner Learning (3) editing scripts

Source: Internet
Author: User

In addition to the CMD direct operation of the phone, you can also edit the script, run the script, one time to manipulate multiple script commands

A) Create a new py format script, such as ireader.py

b) Edit the script #导入模块

From Com.android.monkeyrunner import Monkeyrunner, monkeydevice,monkeyimage

Monkeyrunner.sleep (1)

#连接设备

device = Monkeyrunner.waitforconnection ()

#滑动解销

Device.drag ((360,1008), (616,1016), 0.1,10) Monkeyrunner.sleep (2)

#点击Home键

Device.press (' Keycode_home ', ' down_and_up ')

#导入安装包并安装

Device.installpackage (' E ' \haitao.apk ')

#启动程序

Device.startactivity (component= ' component= ' com.shantao/com.shantao.launchactivity ')

#登录输入

Device.type (' 123456 ')

c) Run the script, under the cmd window

Input Monkeyrunner F:\iReader.py

Basic can be run, the script is running faster, the middle time lag comparison good monkeyrunner.sleep (1)

Monkeyrunner Learning (3) editing scripts

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.