0

I'm running AndroidViewClient and am able to dump a complete hierarchy, but things fail when I try to getXY() or touch(). Even the solution from Get Current Focused Window Name using AndroidViewClient gives me an error.

  kwargs1 = {'verbose': True, 'ignoresecuredevice': True}
  kwargs2 = {'startviewserver': True, 'forceviewserveruse': True,
             'autodump': False, 'ignoreuiautomatorkilled': True}
  device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
  vc = ViewClient(device, serialno, **kwargs2)
  view = vc.dump(window='-1')
  widget = vc.findViewByIdOrRaise("id/no_id/5")
  widget.useUiAutomator = False
  print widget
  # Up until here runs no problem.
  print widget.getXY() # fails.
  widget.touch() # also fails.

My stack trace goes something like:

print widget.getXY()

File "/usr/local/lib/python2.7/dist-packages/androidviewclient-11.5.3-py2.7.egg/com/dtmilano/android/viewclient.py", line 680, in getXY (wvx, wvy) = self.__dumpWindowsInformation(debug=debug)

File "/usr/local/lib/python2.7/dist-packages/androidviewclient-11.5.3-py2.7.egg/com/dtmilano/android/viewclient.py", line 798, in __dumpWindowsInformation

dww = self.device.shell('dumpsys window windows')

File "/usr/local/lib/python2.7/dist-packages/androidviewclient-11.5.3-py2.7.egg/com/dtmilano/android/adb/adbclient.py", line 377, in shell

self.__send('shell:%s' % cmd, checkok=True, reconnect=False)

File "/usr/local/lib/python2.7/dist-packages/androidviewclient-11.5.3-py2.7.egg/com/dtmilano/android/adb/adbclient.py", line 243, in __send

self.__checkOk()

File "/usr/local/lib/python2.7/dist-packages/androidviewclient-11.5.3-py2.7.egg/com/dtmilano/android/adb/adbclient.py", line 286, in __checkOk

raise RuntimeError("ERROR: %s %s" % (repr(recv), error))

RuntimeError: ERROR: ''

Any thoughts?

Community
  • 1
  • 1

1 Answers1

0
widget = vc.findViewByIdOrRaise("id/no_id/5")
widget.useUiAutomator = False
widget.getXY() 
x = (str)widget.windows[widget.currentFocus] 
print x

Above code will get the Display Activity name and height and width of the screen,if u want only height and width refer below one

h = device._AdbClient__getDisplayHeight("")
w = device._AdbClient__getDisplayWidth("")
print (str)(h)
print (str)(w)
Arun Sai
  • 1
  • 3