我正在使用一个可以在DroidBox23上工作的monkeyrunner脚本,它是DroidBox程序中默认出现的脚本,在脚本文件夹中,但是我通过这种方式进行了修改:
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)
感谢您的帮助。