#! /usr/bin/env python ''' Copyright (C) 2012 Diego Torres Milano Created on Sep 8, 2012 @author: diego @see: http://code.google.com/p/android/issues/detail?id=36544 ''' 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, View device, serialno = ViewClient.connectToDeviceOrExit() DEBUG = True FLAG_ACTIVITY_NEW_TASK = 0x10000000 # We are not using Settings as the bug describes because there's no WiFi dialog in emulator componentName = 'com.android.settings/.Settings'
@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, TextView, EditText device, serialno = ViewClient.connectToDeviceOrExit() vc = ViewClient(device=device, serialno=serialno) #send = vc.findViewWithTextOrRaise('Send') send = vc.findViewByIdOrRaise('id/send') #to = EditText(vc.findViewByIdOrRaise('id/to')) to = vc.findViewByIdOrRaise('id/to') subject = vc.findViewByIdOrRaise('id/subject') subject.touch() subject.type('AVCSample') ViewClient.sleep(10) to.touch() #to.type('*****@*****.**') device.type('*****@*****.**') ViewClient.sleep(10) send.touch()
#! /usr/bin/env python # -*- coding: utf-8 -*- ''' Copyright (C) 2013-2018 Diego Torres Milano Created on 2018-03-29 by Culebra v15.0.1 __ __ __ __ / \ / \ / \ / \ ____________________/ __\/ __\/ __\/ __\_____________________________ ___________________/ /__/ /__/ /__/ /________________________________ | / \ / \ / \ / \ \___ |/ \_/ \_/ \_/ \ o \ \_____/--< @author: Diego Torres Milano @author: Jennifer E. Swofford (ascii art snake) ''' import sys from androidviewclient3.viewclient import ViewClient TAG = 'CULEBRA' _s = 5 _v = '--verbose' in sys.argv kwargs1 = { 'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False } device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1) kwargs2 = { 'forceviewserveruse': False, 'useuiautomatorhelper': False, 'ignoreuiautomatorkilled': True,
#! /usr/bin/env python ''' Copyright (C) 2012 Diego Torres Milano Created on Sep 8, 2012 @author: diego @see: http://code.google.com/p/android/issues/detail?id=36544 ''' 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 device, serialno = ViewClient.connectToDeviceOrExit() FLAG_ACTIVITY_NEW_TASK = 0x10000000 # We are not using Settings as the bug describes because there's no WiFi dialog in emulator #componentName = 'com.android.settings/.Settings' componentName = 'com.dtmilano.android.sampleui/.MainActivity'
#! /usr/bin/env python ''' Copyright (C) 2012 Diego Torres Milano Created on Aug 15, 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, View START_ACTIVITY = True FLAG_ACTIVITY_NEW_TASK = 0x10000000 package = 'com.android.settings' activity = '.Settings' component = package + "/" + activity device, serialno = ViewClient.connectToDeviceOrExit() if START_ACTIVITY: device.startActivity(component=component, flags=FLAG_ACTIVITY_NEW_TASK) ViewClient.sleep(3) vc = ViewClient(device, serialno) # this may help you find the attributes for specific Views #vc.traverse(vc.getRoot()) text = 'Display' view = vc.findViewWithText(text) if view:
#! /usr/bin/env python ''' Copyright (C) 2012 Diego Torres Milano Created on Oct 12, 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 VPS = "javascript:alert(document.getElementsByTagName('html')[0].innerHTML);" USE_BROWSER = True if USE_BROWSER: package = 'com.android.browser' activity = '.BrowserActivity' _id = 'id/no_id/12' else: package = 'com.android.chrome' activity = 'com.google.android.apps.chrome.Main' _id = 'id/no_id/28' component = package + "/" + activity uri = 'http://dtmilano.blogspot.com' device, serialno = ViewClient.connectToDeviceOrExit() device.startActivity(component=component, uri=uri) ViewClient.sleep(5)
#! /usr/bin/env python # -*- coding: utf-8 -*- """ Copyright (C) 2013-2018 Diego Torres Milano Created on 2018-03-29 by Culebra v15.1.0 __ __ __ __ / \ / \ / \ / \ ____________________/ __\/ __\/ __\/ __\_____________________________ ___________________/ /__/ /__/ /__/ /________________________________ | / \ / \ / \ / \ \___ |/ \_/ \_/ \_/ \ o \ \_____/--< @author: Diego Torres Milano @author: Jennifer E. Swofford (ascii art snake) """ import re import sys import os try: sys.path.insert( 0, os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src')) except: pass from androidviewclient3.viewclient import ViewClient TAG = 'CULEBRA' _s = 5 _v = '--verbose' in sys.argv kwargs1 = { 'ignoreversioncheck': False, 'verbose': False,
#! /usr/bin/env python ''' Copyright (C) 2012 Diego Torres Milano Created on Mar 13, 2012 @author: diego ''' import re import sys import os import string try: sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src')) except: pass from androidviewclient3.viewclient import ViewClient USE_BROWSER = True # Starting: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.android.browser/.BrowserActivity } if USE_BROWSER: package = 'com.android.browser' activity = '.BrowserActivity' else: package = 'com.android.chrome' activity = 'com.google.android.apps.chrome.Main' component = package + "/" + activity uri = 'http://dtmilano.blogspot.com' device, serialno = ViewClient.connectToDeviceOrExit() device.startActivity(component=component, uri=uri) ViewClient.sleep(5) vc = ViewClient(device, serialno)
#! /usr/bin/env python ''' Copyright (C) 2012 Diego Torres Milano Created on Sep 5, 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, View device, serialno = ViewClient.connectToDeviceOrExit() FLAG_ACTIVITY_NEW_TASK = 0x10000000 #09-06 01:01:34.964: I/ActivityManager(873): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.android.apis/.ApiDemos bnds=[784,346][880,442]} from pid 991 componentName = 'com.example.android.apis/.ApiDemos' device.startActivity(component=componentName, flags=FLAG_ACTIVITY_NEW_TASK) ViewClient.sleep(3) vc = ViewClient(device=device, serialno=serialno) app = vc.findViewWithText('App') if app: app.touch() ViewClient.sleep(3) # windows changed, request a new dump vc.dump() ad = vc.findViewWithText('Alert Dialogs') if ad:
#! /usr/bin/env python ''' Copyright (C) 2012 Diego Torres Milano Created on Feb 1, 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 package = 'com.android.settings' activity = '.Settings' component = package + "/" + activity device, serialno = ViewClient.connectToDeviceOrExit() if True: device.startActivity(component=component)
#! /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():