|
刚学习了一天,简单copy了个截图的代码,貌似只成功了一次,之后全部都报一样的错误。
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
device = MonkeyRunner.waitForConnection()
#device.press('KEYCODE_HOME',MonkeyDevice.DOWN_AND_UP)
pict = device.takeSnapshot()
MonkeyRunner.sleep(2)
pict.writeToFile(r'C:\WuZhongjian\Doc\pic2.png','png')
下面是命令行窗口报得错误:
C:\Windows\System32>monkeyrunner C:\WuZhongjian\Doc\Android\Test4.py
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] Unable t
o take snapshot
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice]java.io.I
OException: EOF
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.ddmlib.AdbHelper.read(AdbHelper.java:874)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.ddmlib.AdbHelper.getFrameBuffer(AdbHelper.java:333)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.ddmlib.Device.getScreenshot(Device.java:545)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.ddmlib.Device.getScreenshot(Device.java:539)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.chimpchat.adb.AdbChimpDevice.takeSnapshot(AdbChimpDevice.java:210)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.monkeyrunner.MonkeyDevice.takeSnapshot(MonkeyDevice.java:92)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.r
eflect.NativeMethodAccessorImpl.invoke0(Native Method)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.r
eflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.r
eflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.
lang.reflect.Method.invoke(Method.java:498)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyObject.__call__(PyObject.java:387)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyObject.__call__(PyObject.java:391)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyMethod.__call__(PyMethod.java:109)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.pycode._pyx0.f$0(C:\WuZhongjian\Doc\Android\Test4.py:10)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.pycode._pyx0.call_function(C:\WuZhongjian\Doc\Android\Test4.py)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyTableCode.call(PyTableCode.java:165)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.PyCode.call(PyCode.java:18)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.Py.runCode(Py.java:1275)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.core.__builtin__.execfile_flags(__builtin__.java:522)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at org.p
ython.util.PythonInterpreter.execfile(PythonInterpreter.java:225)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77)
190702 11:17:02.921:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at com.a
ndroid.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:189)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] Scri
pt terminated due to an exception
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]Trace
back (most recent call last):
File "C:\WuZhongjian\Doc\Android\Test4.py", line 9, in <module>
photos=photos.getSubImage((42,32,1000,224))
at com.android.monkeyrunner.MonkeyImage.getSubImage(MonkeyImage.java:159
)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.NullPointerException: java.lang.NullPointerException
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.Py.JavaError(Py.java:495)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.Py.JavaError(Py.java:488)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyObject.__call__(PyObject.java:404)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyObject.__call__(PyObject.java:408)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyMethod.__call__(PyMethod.java:124)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.pycode._pyx0.f$0(C:\WuZhongjian\Doc\Android\Test4.py:10)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.pycode._pyx0.call_function(C:\WuZhongjian\Doc\Android\Test4.py)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyTableCode.call(PyTableCode.java:165)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyCode.call(PyCode.java:18)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.Py.runCode(Py.java:1275)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.__builtin__.execfile_flags(__builtin__.java:522)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:225)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:18
9)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]Cause
d by: java.lang.NullPointerException
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at com.android.monkeyrunner.MonkeyImage.getSubImage(MonkeyImage.java:159)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.
java:43)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at java.lang.reflect.Method.invoke(Method.java:498)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
190702 11:17:02.946:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
... 14 more
|
|