某些真实设备的Monkeyrunner错误

时间:2012-11-29 03:22:35

标签: android monkeyrunner

代码很简单

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
device = MonkeyRunner.waitForConnection()
device.touch(84, 712, "DOWN_AND_UP")

可以在模拟器和我的SE Xperia Ray上运行,

但当我在其他设备上运行时,这种设备不在市场上销售。

弹出

错误信息。

可以运行一些命令,例如,使用“snapShot”

但是对于“触摸”“按”,总是失败。

对于某些设备来说,它是否会出现一些bugruuner错误

或问题在设备上,可能修改后的设备源代码存在问题。

我在网上搜索过,找不到解决办法,

我需要决定在设备上使用monkeyruuner,

所以,我需要一些帮助。

抱歉我的英语:)

错误日志是

121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] Error se
nding touch event: 84 712 DOWN_AND_UP
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice]java.net.
SocketException: Software caused connection abort: socket write error
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.
net.SocketOutputStream.socketWrite0(Native Method)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.
net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.
net.SocketOutputStream.write(SocketOutputStream.java:136)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.n
io.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.n
io.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:272)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.n
io.cs.StreamEncoder.implFlush(StreamEncoder.java:276)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.n
io.cs.StreamEncoder.flush(StreamEncoder.java:122)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.
io.OutputStreamWriter.flush(OutputStreamWriter.java:212)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.
io.BufferedWriter.flush(BufferedWriter.java:236)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.chimpchat.ChimpManager.sendMonkeyEventAndGetResponse(ChimpManager.java:18
6)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.chimpchat.ChimpManager.sendMonkeyEvent(ChimpManager.java:234)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.chimpchat.ChimpManager.tap(ChimpManager.java:329)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.chimpchat.adb.AdbChimpDevice.touch(AdbChimpDevice.java:361)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.monkeyrunner.MonkeyDevice.touch(MonkeyDevice.java:136)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.r
eflect.NativeMethodAccessorImpl.invoke0(Native Method)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.r
eflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.r
eflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.
lang.reflect.Method.invoke(Method.java:597)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyReflectedFunction.__call__(PyReflectedFunction.java:175)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyObject.__call__(PyObject.java:355)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyMethod.__call__(PyMethod.java:215)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyMethod.instancemethod___call__(PyMethod.java:221)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyMethod.__call__(PyMethod.java:206)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyObject.__call__(PyObject.java:432)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyObject.__call__(PyObject.java:436)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.pycode._pyx0.f$0(d:\1234.py:18)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.pycode._pyx0.call_function(d:\1234.py)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyTableCode.call(PyTableCode.java:165)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyCode.call(PyCode.java:18)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.Py.runCode(Py.java:1197)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.__builtin__.execfile_flags(__builtin__.java:538)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.util.PythonInterpreter.execfile(PythonInterpreter.java:156)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77)
121129 10:56:42.227:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:189)

1 个答案:

答案 0 :(得分:0)

问题可能在于获得连接

device = MonkeyRunner.waitForConnection()

,遗憾的是设备永远不会None,因此要验证它,您可以采用与ViewClient相同的方法,使用此代码段

device = MonkeyRunner.waitForConnection()
try:
        device.wake()
except java.lang.NullPointerException, e:
        print >> sys.stderr, "%s: ERROR: Couldn't connect to %s: %s" % (progname, serialno, e)
        sys.exit(3)