Eclipse + python + monkeyrunner Environment building

Source: Internet
Author: User

Install Python

Http://pydev.org/updates

Load Python.exe

Jython load Jython package, load hier package chilm Package

》》》》》》》》》》》》》》》》》》》》》》》》》》

Monkeyrunner record playback script, save as mr_rocorder.py

From Com.android.monkeyrunner import Monkeyrunner as Mr

From Com.android.monkeyrunner.recorder import Monkeyrecorder as Recorder

device = Mr.waitforconnection ()

Recorder.start (device)

Run Monkeyrunner mr_rocorder.py

monkeyplayback.py

Import Sys

Com.android.monkeyrunner Import Monkeyrunner

# The format of the file we are parsing is very carfeully constructed.

# each line corresponds to a single command. The line was split into 2

# Parts with a | Character. Text to the left of the pipe denotes

# which command to run. The text to the right of the pipe is a python

# dictionary (it can be evaled to existence) that specifies the

# Arguments for the command. In most cases, this directly maps to the

# keyword argument dictionary that could being passed to the underlying

# command.

# Lookup table to map command strings to functions this implement that

# command.

Cmd_map = {

"TOUCH": Lambda Dev, Arg:dev.touch (**arg),

"DRAG" ": Lambda Dev, Arg:dev.drag (**arg),

"Press": Lambda Dev, arg:dev.press (**arg),

"TYPE": Lambda Dev, Arg:dev.type (**arg),

"WAIT" ": Lambda Dev, arg:MonkeyRunner.sleep (**arg)

}

# Process A single file for the specified device.

def process_file (FP, device):

For line in FP:

(cmd, rest) = Line.split ("" | "" )

Try

# Parse The Pydict

Rest = eval (rest)

Except

Print "Unable to parse options"

Continue

If cmd not in Cmd_map:

print "" Unknown Command: "" + cmd

Continue

Cmd_map[cmd] (device, rest)

def main ():

FILE = sys.argv[1]

fp = open (file, "R")

device = Monkeyrunner.waitforconnection ()

Process_file (FP, device)

Fp.close ();

if __name__ = = "" __main__ "":

Main ()

Run monkeyplayback.py + recorded file name

Install FindBugs:http://findbugs.cs.umd.edu/eclipse installed in Eclipse

Use tcpdump and Wireshark to grab the bag:

ADB push <tcpdump path>/data/local/tcpdump

ADB shell chmod 6755/data/local/tcpdump

ADB shell

Cd/data/local

Tcpdump-p-vv-s 0-w/data/local/capture.pcap

ADB pull/data/local/capture.pcap d:\

Analyze network time-consuming, network protocol IP address, etc.

Detailed view of TCP, IP protocol Volume One to volume three

Eclipse + python + monkeyrunner Environment building

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.