有没有办法在字典中存储转储并在以后使用这些转储,以便不必每次都重新计算转储?这是一个更多的概念验证问题,因为我正在寻找一种方法来加速androidviewclient的慢转储过程,并以任何方式使我的脚本更快。例如,AVC在我的脚本步骤之间返回主屏幕,但需要在重新调整之前再次转储('''''''&#39 ;)按钮几次。
这是有问题的,因为它会创建不必要的等待时间,因为我的脚本正在尝试尽快配置设备的设置并启动应用程序。我想创建一次主屏幕转储,存储它,并返回我存储的转储点击(u''''''&# 39;)步骤之间的按钮,或者有一些创建更快脚本的替代方法。如果这是不可能的,我想知道其他脚本编写软件比AVC更快地工作而不牺牲有效性,因为我喜欢与查找视图/按钮的一致性,并且重写我的功能但慢速脚本没有问题。
到目前为止,我已经搜索过,一无所获,并在查看viewclient.py后尝试了以下内容:
dictDump = {}
home() #helper method that goes to the home screen
dictDump['homeScreen'] = vc.dump()
vc.findViewWithContentDescription(u'''Applications''').touch()
dictDump['appScreen'] = vc.dump()
home()
vc.views = dictDump['homeScreen']
vc.findViewWithContentDescription(u'''Applications''').touch()
我得到:AttributeError:' NoneType'对象没有属性'触摸'
答案 0 :(得分:0)
这是一个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')
该脚本保留对应用的引用并重复使用。 保留参考可能在许多其他情况下不起作用,但因为主屏幕或应用程序按钮变化的可能性很小,您可能没问题。