这是一个culebra生成的脚本,稍作修改,以满足您的要求。在#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
Copyright (C) 2013-2016 Diego Torres Milano
Created on 2016-06-21 by Culebra v11.5.9
__ __ __ __
/ \ / \ / \ / \
____________________/ __\/ __\/ __\/ __\_____________________________
___________________/ /__/ /__/ /__/ /________________________________
| / \ / \ / \ / \ \___
|/ \_/ \_/ \_/ \ o \
\_____/ <
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
'''
import re
import sys
import os
from com.dtmilano.android.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, 'autodump': False, 'startviewserver': True, 'compresseddump': True}
vc = ViewClient(device, serialno, **kwargs2)
device.press('HOME')
vc.dump(window=-1)
# let's keep the reference to apps (dangerous but possible)
apps = vc.findViewWithContentDescriptionOrRaise(u'''Apps''')
apps.touch()
vc.sleep(_s)
vc.dump(window=-1)
vc.findViewWithContentDescriptionOrRaise(u'''API Demos''').touch()
device.press('HOME')
# use the reference we kept
apps.touch()
vc.dump(window=-1)
browser = vc.findViewWithContentDescriptionOrRaise(u'''Browser''')
browser.touch()
device.press('HOME')
该脚本保留对应用程序的引用并重用它。
在许多其他情况下,保留参考可能不起作用,但因为主屏幕或应用程序的按钮不太可能改变,所以你可能没问题。在