51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1699|回复: 4
打印 上一主题 下一主题

Monkeyrunner截图报错

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2019-7-2 11:32:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
刚学习了一天,简单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
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
 楼主| 发表于 2019-7-2 11:33:02 | 只看该作者
有大神嘛  帮助解答下  困扰了一天了
回复 支持 反对

使用道具 举报

  • TA的每日心情
    奋斗
    昨天 09:17
  • 签到天数: 1807 天

    连续签到: 1 天

    [LV.Master]测试大本营

    3#
    发表于 2019-7-2 13:49:09 | 只看该作者
    把截图写入的路径更换一下试试呢,C盘权限挺多
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    4#
     楼主| 发表于 2019-7-2 15:23:39 | 只看该作者
    海海豚 发表于 2019-7-2 13:49
    把截图写入的路径更换一下试试呢,C盘权限挺多

    这个也考虑过了,插个U盘进去也不行。把路径那行注释了,我发现也报错,就是说device.takeSnapshot()这个东东就会报错。。。
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    5#
     楼主| 发表于 2019-7-3 14:28:57 | 只看该作者
    自己更新下最新进展,用了个老的安卓6.0的手机,完全没有问题
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-26 04:09 , Processed in 0.069794 second(s), 23 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表