0

Is there some way to store dumps in a dictionary and use these dumps at a later time so that the dump does not have to be recalculated every time? This is a more a proof of concept question as I'm looking for a way to speed up androidviewclient's slow dump process and make my script quicker in any manner. For instance, AVC returns to the home-screen between my script's steps but needs to dump again before refinding the (u'''Applications''') button a few times.

This is problematic as it creates unnecessary wait times as my script is trying to configure the device's settings as quickly as possible and launch apps. I would like to create the home-screen dump once, store it, and refer back to that dump that I stored to click the (u'''Applications''') button between steps, or have some alternative method of creating a faster script. If this isn't possible, I would like to know what other script writing software works more quickly than AVC without sacrificing effectiveness as I do like the consistency with find views/buttons, and rewriting my functional yet slow script is no problem.

So far I have searched, found nothing, and tried the following after looking through 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()

And I get: AttributeError: 'NoneType' object has no attribute 'touch'

1 Answers1

0

This is a culebra generated script slightly modified to do what you are asking for.

#! /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')

The script keeps the reference to apps and reuse it. Keeping the reference may not work in many other situations but because it's very unlikely the the home screen or the Apps button change you may be fine.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134