""" GUI Automated Testing This module contains base class of all forms. """ __author__ = "Lukas Cenovsky (lukas.cenovsky@bakalari.cz)" __version__ = "0.1" __date__ = "July 2008" __copyright__ = "Copyright (c) 2008 Lukas Cenovsky" from BaseComponent import BaseComponent class Form(BaseComponent): """ base class holding common properties and methods for all forms """ # the following methods are considered private def __init__(self, aControl, aGUIAT): """ Form constructor @aControl - .NET component object @aGUIAT - GUIAT main object """ BaseComponent.__init__(self, aControl, aGUIAT) self._AnalyzeStructure(aControl) def _AnalyzeStructure(self, aControl=None, aResult=None, aLevel=' '): """ analyze the structure of the form; fill self._guiatComponents dictionary the initial call is just with aControl parameter - that is the object we want to analyze (the form) - see GUIAT.Run method the recursive calls are with all parameters: aControl - the object we are going to inspect aResult - dictionary where the found components should be stored aLevel - for pretty printing of hierarchy of the objects the result is dictionary of objects: {component_name: component} the component can contains the same structured dictionary of its components (self._guiatComponents[0]._guiatComponents[0]._guiatComponents and so on) """ if aControl == None: aControl = self._control if aResult == None: print'"%s" (%s)' % (aControl.Name, aControl.GetType().Name) self._guiatComponents = {} aResult = self._guiatComponents for c in aControl.Controls: try: print'%s"%s" (%s)' % (aLevel, c.Name, c.GetType().Name) except Exception, e: print '\n\n%s%s\n%s\n' % (aLevel, c, e) aResult[c.Name] = BaseComponent(c, self._guiat) self._AnalyzeStructure(c, aResult[c.Name]._guiatComponents, aLevel+' ')