I’ve got a monkeyrunner script that is trying to get some information on one of the views, like so:
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)
here’s the output of the dir(v) step:
['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'getAccessibilityIds', 'getChecked', 'getChildren', 'getEnabled', 'getFocused', 'getLocation', 'getParent', 'getSelected', 'getText', 'getViewClass', 'setFocused', 'setSelected']
however, when I try and use the v.getLocation() method, I get the exception below right away.
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
Is anybody familiar with ChimpChat? I undestand it’s some of the core code for MonkeyRunner. What is the relationship between accessibility and MonkeyRunner, and why is it complaining that an accessibility event hasn’t happened yet? Do I need to start some sort of accessibility or instrumentation service?
Thanks.
You are right. It doesn’t work. However you can use AndroidViewClient, which actually works, and the script would be:
and prints something like
which I doubt is your intention unless you are expecting your view to move.