AndroidViewClient:商店查看客户端转储



是否有某种方法可以将转储存储在词典中并在以后使用这些转储,以便每次不必重新计算转储?当我正在寻找一种加快AndroidViewClient的慢速转储过程并以任何方式使我的脚本更快的方法,这是一个更概念性问题的证明。例如,AVC返回我脚本的步骤之间的主屏幕,但需要再次倒入(u''''''''')按钮几次。

这是有问题的,因为它会创建不必要的等待时间,因为我的脚本正在尝试尽快配置设备的设置并启动应用程序。我想一次创建一次主屏幕转储,将其存储,然后参考我存储的我存储的转储,以在步骤之间单击(u''''''''')按钮,或者有一些替代方法可以更快地创建一个替代方法脚本。如果不可能,我想知道其他脚本编写软件比AVC更快地工作,而不会牺牲有效性,因为我喜欢与查找视图/按钮的一致性,并且重写我的功能性但缓慢的脚本没问题。

到目前为止
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:'nontype'对象没有属性'touch'

这是一个 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')

脚本将引用 apps 并重复使用。保留参考可能在许多其他情况下可能无法使用,但是因为它不太可能是主屏幕或 apps 按钮更改,您可能会很好。

最新更新