1

我正在使用一个在 DroidBox23 上运行的 monkeyrunner 脚本,它是默认出现在 DroidBox 程序中的脚本,位于文件夹 scripts/ 中,但我通过这种方式进行了修改:

    import re
    import sys
    import os
    import time

    from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

    device = MonkeyRunner.waitForConnection()
    device.installPackage(sys.argv[1])
    package = sys.argv[2]
    activity = sys.argv[3]

    # sets the name of the component to start
    runComponent = package + '/' + activity
    print "Running: " + runComponent
    # Runs the component
    device.startActivity(component=runComponent)

    time.sleep(5)
    # Takes a screenshot
    print "Taking snapshot"
    result = device.takeSnapshot()
    # Writes the screenshot to a file
    result.writeToFile('shot1.png','png')
    print 'pulsamos'
    device.press("DPAD_UP", 'DOWN_AND_UP')
    print 'pulsado'
    device.touch(60,350, 'DOWN_AND_UP')

当它执行 device.press() 或 device.touch() 时,这些函数不起作用:

    130509 17:23:38.641:S [main] [com.android.chimpchat.adb.AdbChimpDevice] Error sending touch event: 60 350 DOWN_AND_UP
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice]java.net.SocketException: Broken pipe
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.socketWrite0(Native Method)
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.socketWrite(Unknown Source)
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.write(Unknown Source)
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.implFlush(Unknown Source)
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.flush(Unknown Source)

谢谢你的帮助。

4

0 回答 0