问题描述
是github上回购,允许你直接调用的意见,而无需指定与monkeyrunner精确坐标。我有麻烦,虽然实际使用它。
的注:我使用Windows 的
在CMDLINE如果我输入:
monkeyrunner test.py
和test.py包括:
#导入此程序使用的monkeyrunner模块
从com.android.monkeyrunner进口MonkeyRunner,MonkeyDevice#连接到当前设备,返回一个对象MonkeyDevice
设备= MonkeyRunner.waitForConnection()#presses菜单按钮
装置。preSS('KEY code_MENU',MonkeyDevice.DOWN_AND_UP)
然后,动作条溢出按钮获得的点击。
如果我编辑test.py任何的AndroidViewClient例子就没有做任何事情。
任何想法?我不知道如果我正确实施AndroidViewClient。
编辑:
我没有设置AndroidViewClient的唯一的事情就是下载从GitHub的.zip,然后我把它添加到我的环境变量是这样的:
当我尝试运行 monkeyrunner dump.py
:
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]得离谱
由于PT终止异常
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]跟踪
背面(最新最后调用):
文件C:\\用户\\ EgamerHDK \\ Android的SDK \\工具\\ dump.py,第29行,上述<&模块GT;
从com.dtmilano.android.viewclient进口ViewClient
导入错误:没有模块名为dtmilano130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.core.Py.ImportError(Py.java:264)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.core.imp.import_logic(imp.java:692)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.core.imp.import_name(imp.java:746)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.core.imp.importName(imp.java:791)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.core.ImportFunction .__调用__(__ builtin__.java:1236)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.core.PyObject .__调用__(PyObject.java:367)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.core .__内置__.__进口__(__ builtin__.java:1207)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.core.imp.importFromAs(imp.java:869)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.core.imp.importFrom(imp.java:845)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.py code._pyx0.f $ 0(C:\\用户\\ EgamerHDK \\ Android的SDK \\工具\\ dump.py:78)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.py code._pyx0.call_function(C:\\用户\\ EgamerHDK \\ Android的SDK \\工具\\转储。
PY)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.core.PyTable code.call(PyTable code.java:165)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.core.Py code.call(PY code.java:18)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.core.Py.run code(Py.java:1197)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.core .__内置__。execfile_flags(__ builtin__.java:538)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在org.python.util.PythonInter preter.execfile(PythonInter preter.java:156)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116)
130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77)130419 02:46:57.869:S [主] [com.android.monkeyrunner.MonkeyRunnerOptions]
在com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:18
9)
键入完整路径:
C:\\用户\\ EGamerHDK \\ Android的SDK \\工具> monkeyrunner C:\\ AndroidViewClient主\\穿心莲内酯
idViewClient主\\ AndroidViewClient \\例子\\ dump.py
无法打开指定的脚本文件
用法:monkeyrunner [选项] SCRIPT_FILE -s MonkeyServer IP地址。
-p MonkeyServer TCP端口。
-v MonkeyServer日志记录级别(ALL,最详细,较精细,CONFIG,INFO,
警告,严重,OFF)
在dump.py改变:
从com.dtmilano.android.viewclient进口ViewClient
到
<$p$p><$c$c>sys.path.append('C:\\AndroidViewClient-master\\AndroidViewClient-master\\AndroidViewClient\\src')从com.android.monkeyrunner进口MonkeyRunner,MonkeyDevice
从com.dtmilano.android.viewclient进口ViewClient
和现在的工作。下面是从我的应用程序的示例输出。
android.widget.FrameLayout ID / no_id / 1
android.widget.LinearLayout ID / no_id / 2
android.widget.FrameLayout ID / no_id / 3
android.view.View ID / no_id / 4
android.widget.FrameLayout ID / no_id / 5
android.widget.ImageView ID / no_id / 6
android.widget.LinearLayout ID / no_id / 7
android.widget.LinearLayout ID / no_id / 8
android.widget.TextView ID / no_id / 9标签+ SwipeCompatable
android.widget.LinearLayout ID / no_id / 10
android.widget.ImageButton ID / no_id / 11
android.widget.HorizontalScrollView ID / no_id / 12
android.widget.LinearLayout ID / no_id / 13
android.widget.LinearLayout ID / no_id / 14
android.widget.TextView ID / no_id / 15第1节
android.widget.LinearLayout ID / no_id / 16
android.widget.TextView ID / no_id / 17第2节
android.widget.LinearLayout ID / no_id / 18
android.widget.TextView ID / no_id / 19第3节
android.widget.FrameLayout ID / no_id / 20
android.support.v4.view.ViewPager ID / no_id / 21
android.widget.FrameLayout ID / no_id / 22
android.widget.TextView ID / no_id / 23 1
AndroidViewClient is a github repo that allows you to call on views directly, without specifying exact coordinates with monkeyrunner. I'm having trouble actually using it though.
Note: I'm using Windows
In cmdline if I type:
monkeyrunner test.py
and test.py consists of:
# Imports the monkeyrunner modules used by this program
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
# Presses the Menu button
device.press('KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP)
Then the actionBar overflow button get's clicked.
If I edit test.py to any of the AndroidViewClient examples it will doesn't do anything.
Any ideas? I'm not sure if I'm implementing AndroidViewClient correctly.
EDIT:
The only thing I did to setup AndroidViewClient is download the .zip from github and then I added it to my environment variables like this:
When I try to run monkeyrunner dump.py
:
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] Scri
pt terminated due to an exception
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]Trace
back (most recent call last):
File "C:\Users\EgamerHDK\android-sdk\tools\dump.py", line 29, in <module>
from com.dtmilano.android.viewclient import ViewClient
ImportError: No module named dtmilano
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.Py.ImportError(Py.java:264)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.imp.import_logic(imp.java:692)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.imp.import_name(imp.java:746)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.imp.importName(imp.java:791)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.ImportFunction.__call__(__builtin__.java:1236)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyObject.__call__(PyObject.java:367)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.__builtin__.__import__(__builtin__.java:1207)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.imp.importFromAs(imp.java:869)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.imp.importFrom(imp.java:845)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.pycode._pyx0.f$0(C:\Users\EgamerHDK\android-sdk\tools\dump.py:78)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.pycode._pyx0.call_function(C:\Users\EgamerHDK\android-sdk\tools\dump.
py)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyTableCode.call(PyTableCode.java:165)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyCode.call(PyCode.java:18)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.Py.runCode(Py.java:1197)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.__builtin__.execfile_flags(__builtin__.java:538)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:156)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77)
130419 02:46:57.869:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:18
9)
Typing in the full path:
C:\Users\EGamerHDK\android-sdk\tools>monkeyrunner C:\AndroidViewClient-master\Andro
idViewClient-master\AndroidViewClient\examples\dump.py
Can't open specified script file
Usage: monkeyrunner [options] SCRIPT_FILE
-s MonkeyServer IP Address.
-p MonkeyServer TCP Port.
-v MonkeyServer Logging level (ALL, FINEST, FINER, FINE, CONFIG, INFO,
WARNING, SEVERE, OFF)
In dump.py changed:
from com.dtmilano.android.viewclient import ViewClient
to:
sys.path.append('C:\AndroidViewClient-master\AndroidViewClient-master\AndroidViewClient\src')
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
from com.dtmilano.android.viewclient import ViewClient
and it worked now. Here's a sample output from my app.
android.widget.FrameLayout id/no_id/1
android.widget.LinearLayout id/no_id/2
android.widget.FrameLayout id/no_id/3
android.view.View id/no_id/4
android.widget.FrameLayout id/no_id/5
android.widget.ImageView id/no_id/6
android.widget.LinearLayout id/no_id/7
android.widget.LinearLayout id/no_id/8
android.widget.TextView id/no_id/9 Tabs+SwipeCompatable
android.widget.LinearLayout id/no_id/10
android.widget.ImageButton id/no_id/11
android.widget.HorizontalScrollView id/no_id/12
android.widget.LinearLayout id/no_id/13
android.widget.LinearLayout id/no_id/14
android.widget.TextView id/no_id/15 SECTION 1
android.widget.LinearLayout id/no_id/16
android.widget.TextView id/no_id/17 SECTION 2
android.widget.LinearLayout id/no_id/18
android.widget.TextView id/no_id/19 SECTION 3
android.widget.FrameLayout id/no_id/20
android.support.v4.view.ViewPager id/no_id/21
android.widget.FrameLayout id/no_id/22
android.widget.TextView id/no_id/23 1
这篇关于无法获取AndroidViewClient例如code运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!