Permalink
Browse files

Improved examples

  • Loading branch information...
1 parent b9043a2 commit 1b37d23dc5543507ea07ab0cc69b96f9c3245818 @dtmilano committed Nov 27, 2012
@@ -31,6 +31,6 @@
vc = ViewClient(*ViewClient.connectToDeviceOrExit())
-button = vc.findViewWithText('Show Dialog')
+button = vc.findViewWithTextOrRaise('Show Dialog')
print "button: ", button.getClass(), button.getId(), button.getCoords()
@@ -25,17 +25,16 @@
sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
pass
-from com.dtmilano.android.viewclient import ViewClient
+from com.dtmilano.android.viewclient import ViewClient, ViewNotFoundException
vc = ViewClient(*ViewClient.connectToDeviceOrExit())
# Find the 3 toggle buttons, because the first 2 change their text if they are selected
# we use a regex to find them.
# Once found, we touch them changing their state
for t in [re.compile('Button 1 .*'), re.compile('Button 2 .*'), 'Button with ID']:
- view = vc.findViewWithText(t)
- if view:
- view.touch()
- else:
+ try:
+ vc.findViewWithTextOrRaise(t).touch()
+ except ViewNotFoundException:
print >>sys.stderr, "Couldn't find button with text=", t
@@ -35,7 +35,6 @@
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
-print sys.argv
localViewServer = False
if len(sys.argv) > 1 and sys.argv[1] == '--localViewServer':
localViewServer = True

0 comments on commit 1b37d23

Please sign in to comment.