2012-01-19 107 views
0
#!/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) 
+0

你得到一個睡眠時間<10秒同樣的錯誤? –

+0

是的,即使有1秒鐘,我不知道這是否與氰基mod的使用有關:S – Lukap

+0

這不是一個偉大的英特爾,但我認爲你有一個失敗的管道,因爲你失去了你的經理。 –

回答

0

嗯,我想這是我的cyanogenmod問題。在手機上安裝新的操作系統後,它工作正常。所以問題不在腳本中,它與我的越野車氰基模塊

0

當等待連接超時時發生異常。

儘管文檔提到默認爲永久超時,但我發現設置更高的超時值以及設備ID似乎可以解決此問題。

一個例子MonkeyRunner.waitForConnection(1000, 「模擬器-5554」)