Monkeyrunner's Android Automated Test Learning (I.)

Source: Internet
Author: User

Monkeyrunner to learn, must have started the AVD, if you do not know how to start the AVD, please see my previous article, this article mainly on the simulator I use Monkeyrunner to do the first Test.

1. Path of terminal open Monkeyrunner:/usr/java/sdk/.../tools

2../monkeyrunner

3.from Com.android.monkeyrunner Import Monkeyrunner,monkeydevice,monkeyimage

4.device=monkeyrunner.waitforconnection ()

Connecting AvD and Monkeyrunner

5.device.installpackage (' .../***.apk ')

Install an app to emulator, true to indicate successful installation

6.device.startactivity ("Packagename/startactivity")

How to get PackageName and startactivity

2. Get PackageName,

I installed the apidemos.apk on the phone/simulator and opened it, which can be implemented by the following code:

Import Android
Import Pprint
Droid=android. Android ()
Pacs=droid.getrunningpackages ()
Pprint.pprint (Pacs.result)
So we can get packagename.

3. Get StartActivity

Get startactivity with the code below:

Import Android
Import Pprint
Droid=android. Android ()
Apps=droid.getlaunchableapplications ()
Pprint.pprint (Apps.result)
This will allow you to get to the startactivity.

Http://wenku.baidu.com/link?url= imim-3ulsmftwmlvulgp91fiwctgoramyaq8uvleetepri3qxarmgw-ayi9l0slga3k9w7zzyahie-cwm2uwws-ttgy6aemuahcaaopmtkg

Monkeyrunner's Android Automated Test Learning (I.)

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.