Skip to content

Commit 9089091

Browse files
committed
Added isChecked
- Fixed findObject return
1 parent a732235 commit 9089091

10 files changed

Lines changed: 55 additions & 30 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import setup, find_packages
44

55
setup(name='androidviewclient',
6-
version='12.3.0',
6+
version='12.3.1',
77
description='''AndroidViewClient is a 100% pure python library and tools
88
that simplifies test script creation providing higher level
99
operations and the ability of obtaining the tree of Views present at

src/com/dtmilano/android/adb/adbclient.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
'''
1919
import threading
2020

21-
__version__ = '12.3.0'
21+
__version__ = '12.3.1'
2222

2323
import sys
2424
import warnings
@@ -40,7 +40,6 @@
4040
import re
4141
import signal
4242
import os
43-
import types
4443
import platform
4544

4645
from com.dtmilano.android.window import Window

src/com/dtmilano/android/concertina.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818
@author: Diego Torres Milano
1919
2020
'''
21+
import platform
2122
import random
2223
import subprocess
23-
import platform
2424
import sys
25-
import time
2625

2726
__author__ = 'diego'
28-
__version__ = '12.3.0'
27+
__version__ = '12.3.1'
2928

3029
DEBUG = True
3130

src/com/dtmilano/android/controlpanel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
@author: Ahmed Kasem
2020
'''
2121

22-
__version__ = '12.3.0'
22+
__version__ = '12.3.1'
2323

24-
import sys, os
25-
import Tkinter, tkFileDialog, ttk
24+
import Tkinter
25+
import ttk
2626

27-
from com.dtmilano.android.culebron import Operation, Unit, Color
27+
from com.dtmilano.android.culebron import Operation, Color
2828

2929
class Key:
3030
GOOGLE_NOW='KEYCODE_ASSIST'

src/com/dtmilano/android/culebron.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020
'''
2121
import StringIO
2222
import random
23-
import time
2423
import re
25-
from com.dtmilano.android.common import profileStart
24+
import time
25+
2626
from com.dtmilano.android.common import profileEnd
27+
from com.dtmilano.android.common import profileStart
2728
from com.dtmilano.android.concertina import Concertina
2829

29-
__version__ = '12.3.0'
30+
__version__ = '12.3.1'
3031

3132
import sys
3233
import threading

src/com/dtmilano/android/robotframework/viewclientwrapper.py

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

21-
__version__ = '12.3.0'
21+
__version__ = '12.3.1'
2222
__author__ = 'diego'
2323

2424
import sys
25-
from com.dtmilano.android.viewclient import ViewClient
2625

26+
from com.dtmilano.android.viewclient import ViewClient
2727

2828
"""A library to integrate *AndroidViewClient/culebra* tests with Robotframework.
2929

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

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

21-
__version__ = '12.3.0'
21+
__version__ = '12.4.0'
2222

2323
import json
2424
import os
@@ -248,6 +248,12 @@ def findObject(self, **kwargs):
248248
if DEBUG:
249249
print >> sys.stderr, "UiAutomatorHelper: findObject: returning", int(r[u'oid'])
250250
return UiObject2(self, int(r[u'oid']))
251+
elif r[u'status'] == 'ERROR':
252+
if DEBUG:
253+
print >> sys.stderr, "UiAutomatorHelper: findObject: returning", int(r[u'oid'])
254+
if r[u'statusCode'] == -1:
255+
# Object not found
256+
return None
251257
raise RuntimeError("Error: " + response)
252258

253259
def longClick(self, **kwargs):
@@ -324,6 +330,14 @@ def getText(self, uiObject=None, uiObject2=None):
324330
return r[u'text']
325331
raise RuntimeError("Error: " + response)
326332

333+
def isChecked(self, uiObject=None):
334+
# This path works for UiObject and UiObject2, so there's no need to handle both cases differently
335+
path = '/UiObject/%d/isChecked' % (uiObject.oid)
336+
response = self.__httpCommand(path, None)
337+
r = json.loads(response)
338+
if r[u'status'] == 'OK':
339+
return r[u'checked']
340+
raise RuntimeError("Error: " + response)
327341

328342
#
329343
# UiScrollable
@@ -352,9 +366,16 @@ def uiScrollable(self, path, params = None):
352366

353367

354368
class UiObject:
355-
def __init__(self, uiAutomatorHelper, oid):
369+
def __init__(self, uiAutomatorHelper, oid, response):
356370
self.uiAutomatorHelper = uiAutomatorHelper
357371
self.oid = oid
372+
self.className = response['className']
373+
374+
def getOid(self):
375+
return self.oid
376+
377+
def getClassName(self):
378+
return self.className
358379

359380
def click(self):
360381
self.uiAutomatorHelper.click(oid=self.oid)
@@ -380,6 +401,12 @@ def click(self):
380401
def clickAndWait(self, eventCondition, timeout):
381402
self.uiAutomatorHelper.clickAndWait(uiObject2=self, eventCondition=eventCondition, timeout=timeout)
382403

404+
def isChecked(self):
405+
"""
406+
407+
:rtype: bool
408+
"""
409+
return self.uiAutomatorHelper.isChecked(uiObject=self)
383410

384411
def longClick(self):
385412
self.uiAutomatorHelper.longClick(oid=self.oid)
@@ -414,11 +441,11 @@ def flingToEnd(self, maxSwipes=20):
414441

415442
def getChildByDescription(self, uiSelector, description, allowScrollSearch):
416443
oid, response = self.uiAutomatorHelper.uiScrollable(str(self.oid) + '/getChildByDescription', {'uiSelector': uiSelector, 'contentDescription': description, 'allowScrollSearch': allowScrollSearch})
417-
return UiObject(self.uiAutomatorHelper, oid)
444+
return UiObject(self.uiAutomatorHelper, oid, response)
418445

419446
def getChildByText(self, uiSelector, text, allowScrollSearch):
420447
oid, response = self.uiAutomatorHelper.uiScrollable(str(self.oid) + '/getChildByText', {'uiSelector': uiSelector, 'text': text, 'allowScrollSearch': allowScrollSearch})
421-
return UiObject(self.uiAutomatorHelper, oid)
448+
return UiObject(self.uiAutomatorHelper, oid, response)
422449

423450
def setAsHorizontalList(self):
424451
self.uiAutomatorHelper.uiScrollable(str(self.oid) + '/setAsHorizontalList')

src/com/dtmilano/android/viewclient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@author: Diego Torres Milano
1919
'''
2020

21-
__version__ = '12.3.0'
21+
__version__ = '12.3.1'
2222

2323
import sys
2424
import warnings

tools/culebra

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@ ___________________/ /__/ /__/ /__/ /________________________________
2020
2121
'''
2222

23-
__version__ = '12.3.0'
23+
__version__ = '12.3.1'
2424

25+
import calendar
26+
import codecs
27+
import getopt
28+
import os
2529
import re
2630
import sys
27-
import os
28-
import getopt
2931
import warnings
30-
import subprocess
31-
import codecs
32-
import calendar
3332
from datetime import date
3433

3534
try:

tools/dump

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Created on Feb 3, 2012
66
@author: diego
77
'''
88

9-
__version__ = '12.3.0'
9+
__version__ = '12.3.1'
1010

11-
import sys
12-
import os
13-
import getopt
1411
import ast
12+
import getopt
13+
import os
1514
import re
15+
import sys
1616

1717
try:
1818
sys.path.insert(0, os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))

0 commit comments

Comments
 (0)