AndroidViewClient是一个 github 存储库,它允许您直接调用视图,而无需使用 monkeyrunner 指定确切的坐标。我在实际使用它时遇到了麻烦。
注意:我使用的是 Windows
如果我在命令行中输入:
monkeyrunner test.py
和 test.py 包括:
# 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)
然后点击 actionBar 溢出按钮。
如果我将 test.py 编辑到任何 AndroidViewClient 示例,它不会做任何事情。
有任何想法吗?我不确定我是否正确实现了 AndroidViewClient。
编辑:
我设置 AndroidViewClient 所做的唯一一件事就是从 github 下载 .zip,然后将其添加到我的环境变量中,如下所示:
当我尝试运行时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)
输入完整路径:
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)