Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android monkeyrunner-尝试使用view.getLocation()时出现异常_Android_Jython_Monkeyrunner - Fatal编程技术网

Android monkeyrunner-尝试使用view.getLocation()时出现异常

Android monkeyrunner-尝试使用view.getLocation()时出现异常,android,jython,monkeyrunner,Android,Jython,Monkeyrunner,我有一个monkeyrunner脚本,它试图获取其中一个视图的一些信息,如下所示: v = d.getViewById('id/search_progress_bar') print dir(v) for i in range(10): print 'about to call v.getLocation' print v.getLocation() m.sleep(1) 下面是dir(v)步骤的输出: 然而,当我尝试使用v.getLocation()方法时,我立即得到

我有一个monkeyrunner脚本,它试图获取其中一个视图的一些信息,如下所示:

v = d.getViewById('id/search_progress_bar')
print dir(v)
for i in range(10):
    print 'about to call v.getLocation'
    print v.getLocation()
    m.sleep(1)
下面是dir(v)步骤的输出:

然而,当我尝试使用v.getLocation()方法时,我立即得到下面的异常

121024 16:30:26.373:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
121024 16:30:26.373:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
  File "/Users/swolfe/svn/jython/progress_bar_testing.py", line 20, in <module>
    print v.getLocation()
    at com.android.chimpchat.ChimpManager.queryView(ChimpManager.java:414)
    at com.android.chimpchat.core.ChimpView.queryView(ChimpView.java:52)
    at com.android.chimpchat.core.ChimpView.getLocation(ChimpView.java:64)
    at com.android.monkeyrunner.MonkeyView.getLocation(MonkeyView.java:81)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)

com.android.chimpchat.core.ChimpException: com.android.chimpchat.core.ChimpException: No accessibility event has occured yet
121024 16:30:26.373:S[main][com.android.monkeyrunner.MonkeyRunnerOptions]脚本因异常而终止
121024 16:30:26.373:S[main][com.android.monkeyrunner.monkeyrunner选项]回溯(最近一次通话最后一次):
文件“/Users/swolfe/svn/jython/progress\u bar\u testing.py”,第20行,在
打印v.getLocation()
在com.android.chimpchat.ChimpManager.queryView(ChimpManager.java:414)
位于com.android.chimpchat.core.ChimpView.queryView(ChimpView.java:52)
位于com.android.chimpchat.core.ChimpView.getLocation(ChimpView.java:64)
位于com.android.monkeyrunner.MonkeyView.getLocation(MonkeyView.java:81)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)中
位于java.lang.reflect.Method.invoke(Method.java:597)
com.android.chimpchat.core.ChimpException:com.android.chimpchat.core.ChimpException:尚未发生可访问性事件
有人熟悉黑猩猩聊天吗?我不知道这是MonkeyRunner的一些核心代码。可访问性和MonkeyRunner之间的关系是什么?为什么它抱怨尚未发生可访问性事件?我是否需要启动某种辅助功能或检测服务


谢谢。

你说得对。它不起作用。但是,您可以使用,这实际上是可行的,脚本是:

vc = ViewClient(d, serialno)
v = vc.findViewByIdOrRaise('id/search_progress_bar')
print dir(v)
for i in range(10):
    print 'about to call v.getCoords'
    print v.getCoords()
    m.sleep(1)
并打印出类似于

['_View__dumpWindowsInformation', '_View__obtainPxPy', '_View__obtainStatusBarDimensionsIfVisible', '_View__obtainVwVh', '_View__obtainVxVy', '__call__', '__doc__', '__getattr__', '__getitem__', '__init__', '__module__', '__smallStr__', '__str__', '__tinyStr__', 'add', 'allPossibleNamesWithColon', 'build', 'children', 'currentFocus', 'device', 'factory', 'getCenter', 'getClass', 'getCoords', 'getHeight', 'getId', 'getParent', 'getPositionAndSize', 'getText', 'getUniqueId', 'getVisibility', 'getWidth', 'getX', 'getXY', 'getY', 'intersection', 'map', 'parent', 'touch', 'windows']
about to call v.getCoords
((0, 157), (480, 229))
about to call v.getCords
((0, 157), (480, 229))
...

除非你希望自己的观点有所改变,否则我怀疑你的意图。

谢谢米拉诺,我是你博客的忠实粉丝。当我看到monkeydevice可用的方法时,我想AndroidViewClient可能已经被合并到MR中了。我一定会看看AVC,谢谢!
['_View__dumpWindowsInformation', '_View__obtainPxPy', '_View__obtainStatusBarDimensionsIfVisible', '_View__obtainVwVh', '_View__obtainVxVy', '__call__', '__doc__', '__getattr__', '__getitem__', '__init__', '__module__', '__smallStr__', '__str__', '__tinyStr__', 'add', 'allPossibleNamesWithColon', 'build', 'children', 'currentFocus', 'device', 'factory', 'getCenter', 'getClass', 'getCoords', 'getHeight', 'getId', 'getParent', 'getPositionAndSize', 'getText', 'getUniqueId', 'getVisibility', 'getWidth', 'getX', 'getXY', 'getY', 'intersection', 'map', 'parent', 'touch', 'windows']
about to call v.getCoords
((0, 157), (480, 229))
about to call v.getCords
((0, 157), (480, 229))
...