#!/bin/python
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
import time
import commands
import sys
import string
import random
device = MonkeyRunner.waitForConnection(10)
device.press('KEYCODE_BACK', MonkeyDevice.DOWN_AND_UP)
time.sleep(1)
device.press('KEYCODE_BACK', MonkeyDevice.DOWN_AND_UP)
package = 'com.pak.pak1'
activity = 'com.pak.pak1.Activity123'
runComponent = package + '/' + activity
device.startActivity(component=runComponent)
time.sleep(1)
device.touch( 20, 90, MonkeyDevice.DOWN_AND_UP )
time.sleep(2)
device.touch( 20, 90, MonkeyDevice.DOWN_AND_UP )
#time.sleep(10)
device.touch( 450, 95, MonkeyDevice.DOWN_AND_UP )
如果我像这样运行脚本它工作得很好
但是如果我延迟一些时间 (time.sleep(10)) 那么 ti 会给出这个错误
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] Error getting the manager to quit
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice]java.net.SocketException: Broken pipe
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at java.net.SocketOutputStream.socketWrite0(Native Method)
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:272)
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:276)
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:122)
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:212)
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at java.io.BufferedWriter.flush(BufferedWriter.java:236)
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at com.android.monkeyrunner.MonkeyManager.sendMonkeyEventAndGetResponse(MonkeyManager.java:167)
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at com.android.monkeyrunner.MonkeyManager.quit(MonkeyManager.java:288)
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at com.android.monkeyrunner.adb.AdbMonkeyDevice.dispose(AdbMonkeyDevice.java:79)
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at com.android.monkeyrunner.adb.AdbBackend.shutdown(AdbBackend.java:120)
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:95)
120119 10:31:24.823:S [main] [com.android.monkeyrunner.adb.AdbMonkeyDevice] at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:203)