码迷,mamicode.com
首页 > 编程语言 > 详细

eclipse + python + monkeyrunner环境搭建

时间:2015-06-03 17:10:54      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

安装python

http://pydev.org/updates

加载python.exe

jython 加载jython 包 , 加载Hier包 chilm包

 

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

 

monkeyrunner 录制回放脚本,保存为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)

运行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 is 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 into existence) that specifies the

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

    # keyword argument dictionary that could be passed to the underlying

    # command.

    # Lookup table to map command strings to functions that 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()

 

运行monkeyplayback.py + 录制的文件名

 

安装findbugs:http://findbugs.cs.umd.edu/eclipse  在eclipse中安装

使用tcpdump及wireshark 抓包:

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:\

分析网络耗时、网络协议 IP地址等

详细查看TCP、ip协议卷一到卷三

 

eclipse + python + monkeyrunner环境搭建

标签:

原文地址:http://www.cnblogs.com/collect/p/4549368.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!