Skip to content

Commit ec287de

Browse files
committed
UiAutomatorHelper fixes
- UiObject changed to UiObject2 - Implemented clickAndWait - UiScrollable created
1 parent 8669784 commit ec287de

1 file changed

Lines changed: 31 additions & 3 deletions

File tree

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

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@author: Diego Torres Milano
1919
'''
2020

21-
__version__ = '12.0.2'
21+
__version__ = '12.0.3'
2222

2323
import os
2424
import subprocess
@@ -246,7 +246,7 @@ def findObject(self, **kwargs):
246246
if r[u'status'] == 'OK':
247247
if DEBUG:
248248
print >> sys.stderr, "UiAutomatorHelper: findObject: returning", int(r[u'oid'])
249-
return UiObject(self, int(r[u'oid']))
249+
return UiObject2(self, int(r[u'oid']))
250250
raise RuntimeError("Error: " + response)
251251

252252
def longClick(self, **kwargs):
@@ -291,17 +291,45 @@ def setText(self, uiObject, text):
291291
params = {'text': text}
292292
return self.__httpCommand('/UiObject/0x%x/setText' % (uiObject.oid), params)
293293

294+
#
295+
# UiObject2
296+
#
297+
def clickAndWait(self, uiObject2, eventCondition, timeout):
298+
params = {'eventCondition': eventCondition, 'timeout': timeout}
299+
return self.__httpCommand('/UiObject2/0x%x/clickAndWait' % (uiObject2.oid), params)
300+
301+
302+
#
303+
# UiScrollable
304+
#
305+
def uiScrollable(self, path, params):
306+
return self.__httpCommand('/UiScrollable/' + path, params)
307+
294308

295-
class UiObject:
309+
class UiObject2:
296310
def __init__(self, uiAutomatorHelper, oid):
297311
self.uiAutomatorHelper = uiAutomatorHelper
298312
self.oid = oid
299313

300314
def click(self):
301315
self.uiAutomatorHelper.click(oid=self.oid)
302316

317+
def clickAndWait(self, eventCondition, timeout):
318+
self.uiAutomatorHelper.clickAndWait(uiObject2=self, eventCondition=eventCondition, timeout=timeout)
319+
320+
303321
def longClick(self):
304322
self.uiAutomatorHelper.longClick(oid=self.oid)
305323

306324
def setText(self, text):
307325
self.uiAutomatorHelper.setText(uiObject=self, text=text)
326+
327+
328+
class UiScrollable:
329+
def __init__(self, uiAutomatorHelper, selector):
330+
self.uiAutomatorHelper = uiAutomatorHelper
331+
self.selector = selector
332+
333+
def createUiScrollable(self):
334+
return self.uiAutomatorHelper.uiScrollable('new', {'uiSelector': self.selector})
335+

0 commit comments

Comments
 (0)