# otherwise the import fails. # PyDev sets PYTHONPATH, use it try: for p in os.environ['PYTHONPATH'].split(':'): if not p in sys.path: sys.path.append(p) except: pass try: sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src')) except: pass from androidviewclient3.viewclient import ViewClient package = 'com.example.trashcan' activity = '.FullScreenActivity' component = package + "/" + activity device, serialno = ViewClient.connectToDeviceOrExit() #device.startActivity(component=component) #ViewClient.sleep(3) vc = ViewClient(device, serialno) button = vc.findViewWithTextOrRaise('Button') button.touch() toggle = vc.findViewWithTextOrRaise(re.compile('(ON)|(OFF)')) toggle.touch()
#! /usr/bin/env python ''' Copyright (C) 2012 Diego Torres Milano Created on Aug 31, 2012 @author: diego ''' import re import sys import os # This must be imported before MonkeyRunner and MonkeyDevice, # otherwise the import fails. # PyDev sets PYTHONPATH, use it try: for p in os.environ['PYTHONPATH'].split(':'): if not p in sys.path: sys.path.append(p) except: pass try: sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src')) except: pass from androidviewclient3.viewclient import ViewClient vc = ViewClient(*ViewClient.connectToDeviceOrExit()) button = vc.findViewWithTextOrRaise('Show Dialog') print("button: ", button.getClass(), button.getId(), button.getCoords())
#! /usr/bin/env python ''' Copyright (C) 2012 Diego Torres Milano Created on Aug 31, 2012 @author: diego ''' import re import sys import os # This must be imported before MonkeyRunner and MonkeyDevice, # otherwise the import fails. # PyDev sets PYTHONPATH, use it try: for p in os.environ['PYTHONPATH'].split(':'): if not p in sys.path: sys.path.append(p) except: pass try: sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src')) except: pass from androidviewclient3.viewclient import ViewClient, ViewNotFoundException vc = ViewClient(*ViewClient.connectToDeviceOrExit()) if vc.useUiAutomator: print("ViewClient: using UiAutomator backend") # 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
Copyright (C) 2012 Diego Torres Milano Created on Feb 3, 2012 @author: diego ''' import sys import os # This must be imported before MonkeyRunner and MonkeyDevice, # otherwise the import fails. # PyDev sets PYTHONPATH, use it try: for p in os.environ['PYTHONPATH'].split(':'): if not p in sys.path: sys.path.append(p) except: pass try: sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src')) except: pass from androidviewclient3.viewclient import ViewClient device, serialno = ViewClient.connectToDeviceOrExit(ignoresecuredevice=True) vc = ViewClient(device=device, serialno=serialno, startviewserver=False) vc.findViewWithTextOrRaise("New activity").touch()
#! /usr/bin/env python ''' Copyright (C) 2012 Diego Torres Milano Created on Feb 3, 2012 @author: diego ''' import re import sys import os try: sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src')) except: pass from androidviewclient3.viewclient import ViewClient # 01-04 18:23:42.000: I/ActivityManager(4288): Displayed com.android.development/.DevelopmentSettings: +379ms package = 'com.android.development' activity = '.DevelopmentSettings' component = package + "/" + activity device, serialno = ViewClient.connectToDeviceOrExit() device.startActivity(component=component) ViewClient.sleep(5) vc = ViewClient(device, serialno) showCpu = vc.findViewWithTextOrRaise("Show CPU usage") showLoad = vc.findViewWithTextOrRaise("Show running processes") alwaysFinish = vc.findViewWithTextOrRaise("Immediately destroy activities") if not showLoad.isChecked(): print("touching @", showLoad.getCenter()) showLoad.touch() if not alwaysFinish.isChecked():