Skip to content

Commit 1b37d23

Browse files
committed
Improved examples
1 parent b9043a2 commit 1b37d23

3 files changed

Lines changed: 5 additions & 7 deletions

File tree

AndroidViewClient/examples/sample-ui-dialog_activity-button.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131

3232
vc = ViewClient(*ViewClient.connectToDeviceOrExit())
3333

34-
button = vc.findViewWithText('Show Dialog')
34+
button = vc.findViewWithTextOrRaise('Show Dialog')
3535
print "button: ", button.getClass(), button.getId(), button.getCoords()
3636

AndroidViewClient/examples/sample-ui-toggle-buttons.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,16 @@
2525
sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
2626
except:
2727
pass
28-
from com.dtmilano.android.viewclient import ViewClient
28+
from com.dtmilano.android.viewclient import ViewClient, ViewNotFoundException
2929

3030
vc = ViewClient(*ViewClient.connectToDeviceOrExit())
3131

3232
# Find the 3 toggle buttons, because the first 2 change their text if they are selected
3333
# we use a regex to find them.
3434
# Once found, we touch them changing their state
3535
for t in [re.compile('Button 1 .*'), re.compile('Button 2 .*'), 'Button with ID']:
36-
view = vc.findViewWithText(t)
37-
if view:
38-
view.touch()
39-
else:
36+
try:
37+
vc.findViewWithTextOrRaise(t).touch()
38+
except ViewNotFoundException:
4039
print >>sys.stderr, "Couldn't find button with text=", t
4140

AndroidViewClient/examples/temperature-converter-get-conversion.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
3737

38-
print sys.argv
3938
localViewServer = False
4039
if len(sys.argv) > 1 and sys.argv[1] == '--localViewServer':
4140
localViewServer = True

0 commit comments

Comments
 (0)