Monkeyrunner on Eclipse

Source: Internet
Author: User

Monkeyrunner is an automated test tool provided by Android, and it also provides a Python interface that allows us to control the behavior of the app, such as installing apps, launching apps based on package name, clicking, sliding Events, and more. Using Monkeyrunner in eclipse requires some configuration:

1. Download and install Python;

2.eclipse install the Python plugin;

3. Download and install Jython.jar;

4. Configure Eclipse;

Since the first 3 steps are relatively simple, here is not too much to describe, the 4th step directly.

A. Configure the Python interpreter and click Window->preferences->pydev->interpreters, as shown in:

B. Configure Jython, click Window->preferences->pydev->interpreters, and add Monkeyrunner.jar to libraries, as shown in:


C. Next you can create a Jython project,

d. Finally, the creation of Python code, a simple code, copied from the Android website, this code includes the behavior: Install MYAPPLICATION.APK, Open mainactivity, click menu

from com.android.monkeyrunner import Monkeyrunner, monkeydevice# connects to the Current device, returning a monkeydevice Objectdevice = Monkeyrunner.waitforconnection () # Installs the Android package. Notice that this method returns a Boolean, so can test# to see if the installation Worked.device.installPackage (' Mypro ject/bin/myapplication.apk ') # sets a variable with the package ' s internal namepackage = ' Com.example.android.myapplication ' # Sets a variable with the name of an Activity in the packageactivity = ' Com.example.and  Roid.myapplication.MainActivity ' # Sets the name of the component to Startruncomponent = package + '/' + activity# Runs the Componentdevice.startactivity (component=runcomponent) # presses the Menu buttondevice.press (' KEYCODE_MENU ', MONKEYDEVICE.DOWN_AND_UP) # Takes a screenshotresult = Device.takesnapshot () # writes the screenshot to a Fileresult.writeT Ofile (' myproject/shot1.png ', ' png ') 
E. Run the code, actually I execute this code, rely on Android to provide Monkeyrunner.bat, so do not run the program as usual, right->run-> choose to execute the program, this time to use the Eclipse external Tools, click Run->external tools->external Tools configurations, and then add the relevant configuration information, such as:


Later, every time you execute it, you don't have to add it again.

Reference: http://forum.xda-developers.com/showthread.php?t=2566234


Monkeyrunner on Eclipse

Related Article

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.