51Testing软件测试论坛

标题: 求大神赐教,用monkeyrunner截图时老报错 [打印本页]

作者: 2339073008    时间: 2017-9-20 17:45
标题: 求大神赐教,用monkeyrunner截图时老报错
D:\Program Files\Java\adt-bundle-windows-x86-20130917\sdk\tools>monkeyrunner
Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:54:35)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_144
>>> from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
>>> devices=MonkeyRunner.waitForConnection(5,'4b37ca1d')
>>> devices.startActivity(component = 'com.jiaotong.app/.mvp.module.launch.Splas
hScreenActivity')
>>> devices.touch(351,1292,"DOWN_AND_UP")
>>> MonkeyRunner.sleep(5)
>>> result = device.takeSnapshot()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'device' is not defined
C:\Users\admin\Desktop\QQ截图20170920174330.png

报错
作者: 海海豚    时间: 2017-9-20 18:48
>>> from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
>>> devices=MonkeyRunner.waitForConnection(5,'4b37ca1d')
>>> devices.startActivity(component = 'com.jiaotong.app/.mvp.module.launch.Splas
hScreenActivity')
>>> devices.touch(351,1292,"DOWN_AND_UP")
>>> MonkeyRunner.sleep(5)
>>> result = device.takeSnapshot()
你在上面定义的是“devices”    然后截图时是“device”
这个错误提示的是你的“device”未定义
作者: 2339073008    时间: 2017-9-21 14:20
海海豚 发表于 2017-9-20 18:48
>>> from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
>>> devices=MonkeyRu ...

多谢
作者: 酸子茶    时间: 2017-10-10 14:21
000
作者: 酸子茶    时间: 2017-10-10 14:22
000




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2