Skip to content

Commit 1541b26

Browse files
committed
Support for UiObject and UiObjext2 in getText
1 parent 98bc0c8 commit 1541b26

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/com/dtmilano/android/uiautomator/uiautomatorhelper.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,14 @@ def clickAndWait(self, uiObject2, eventCondition, timeout):
298298
params = {'eventCondition': eventCondition, 'timeout': timeout}
299299
return self.__httpCommand('/UiObject2/%d/clickAndWait' % (uiObject2.oid), params)
300300

301-
def getText(self, uiObject2):
302-
response = self.__httpCommand('/UiObject2/%d/getText' % (uiObject2.oid), None)
301+
def getText(self, uiObject=None, uiObject2=None):
302+
if uiObject:
303+
path = '/UiObject/%d/getText' % (uiObject.oid)
304+
elif uiObject2:
305+
path = '/UiObject2/%d/getText' % (uiObject2.oid)
306+
else:
307+
raise ValueError("No uiObject or uiObject2 specified")
308+
response = self.__httpCommand(path, None)
303309
r = json.loads(response)
304310
if r[u'status'] == 'OK':
305311
if DEBUG:
@@ -342,6 +348,11 @@ def click(self):
342348
def longClick(self):
343349
self.uiAutomatorHelper.longClick(oid=self.oid)
344350

351+
def getText(self):
352+
return self.uiAutomatorHelper.getText(uiObject=self)
353+
354+
def setText(self, text):
355+
self.uiAutomatorHelper.setText(uiObject=self, text=text)
345356

346357

347358
class UiObject2:

0 commit comments

Comments
 (0)