Custom Component Automation – XML Details
Once you are ready with the custom delegate and the setup for listening to the events on your custom control, you may need to add the details of the same in the XML data for your tool.
- You need to add your section of ClassInfo for your custom component.
- Each event which needs to be automated should be procided in the syntax given for Operation.
- Each property which is worth inspecting on the object, should be added in the properties section.
- If you are extending from an existing flex automatable object, please copy the contents of the same from the base class and then add your additions. (e.g if your component is extending from DataGrid, find the section of classInfo corresponding to the same, modify the implementation class, name etc to suit your needs and then add the additional properties and events).
- If you want to use the same details of another object for your custom class, add your class details also under the implementation for the existing one. E.g you have a custom render which has the same properties and events of the DataGridItem renderer, but does not ahve a hierarchical relationship with it. Find the section corresponding to DataGridItem renderer class, under the class infor add an additional entry for your class for the Implementation tag. (Syntax details given below).
(From Flex4 there will be a way to automate custom component evnets without this XML File. I shall cover that in a post soon.)
The section below describes the syntax of the XML for QTP.
Meaning of each of the values is given below.
Note: The fileds which are not explained here, can simply be copied from an existing entry.
ClassInfo -> This corresponds to a class. This can have the two major sub items. TypeInfo and Properies .
The properties and the sub nodes of the class Info are as follows.
Name : – How you want this component to be shown in the script.
Extends :- The class from which this component is extended. This will be the name of the classInfo in the XML file. E.g if the class is extending from UIComponent,find the element in the XML for the UIComponent. Assume if the name of the class in the XML for UIComponent is FlexObject this should be denoted as Extends=”FlexObject”
SupportsTabularData:- This indicates that the object has some data which can be represented in tabular form. This is used in displaying the object property during the checkpoint insertion.
IconInfo :- This gives the details of the location of the IconFile and the index of the icon which can used to represent the current class while represnting this object in the tool (e.g Object repository, property window in QTP).
Description :- Description about the component.
Implementation – Class -> Here user is supposed to give the complete qualified name of the class as follows . (packagename::className) e.g mx.controls::AdvancedDataGrid.
Please note that this is the key information the applocation uses to find the ClassInfo for a particular component.
This node contains a list of <Operation>
This node represents an event or method that is applicable to the current class. For QTP, both flex events and methods are considered as Methods itself. So this section mainly descibes the details of the event or method.
Operation Field details :
Name: – Name of the event/method , how this should be shown in the script.
Implementation -Class -> The complete qualified name of the event class. (This wont be applicable for the methods on the object itself. refer SetFocus method in the sample below)
Implementation – Type -> The type of the event. (If method the method name)
List of Arguments applicable to the event.
Argument Field details :
Name: Name of the event field.
isMandatory: Is it mandatory to have this argument (similar to default argument)
Type-Variant Type – The type of the argument.
Codec – there can an optional details about the codec class to be used if the type is not a basic type.
Description – description of the argument , to show in the code hinting for the script lines in QTP.
This section contains two kind of properties. “ForVerification = true” ForDescription=”true”
ForVerification properties are used for checking the properties on the object while adding check points on this object.
ForDescription properties are used to describe this object in the application. Currently whatever automation framework uses for the base class, you shoul maintain that list as it is. E.g if your class is extending from UIComponent, check for the forDescription properties of the same and ensure to use the properties in your component also.
In addition to the base class, if you think some other property can help to make your component unique in the application (ideally these values should not change for these component during the life cycle of the application), you can add those also.
If you want to use a property of your compoent which is not a basic data type. For this you need to use a codec class which encodes and decodes this value. For samples you can refer automation\src\mx\automation\codec under the automation code available to you in flexbuilder sdk and check the usage of the same. But this needs an integration from the tool library. So I doubt whether custom components can have new codecs other than what is mentioned under the location above.
You can achive the same in your custom component without codec by having a property which represents your complex property in the basic data type. (e.g you have an icon object, which you want to verify. Ofcourse we cannot verify the icon object, instead you can verify the image path associated with it. This only anyway you would have exposed in the codec. So you can have a propery as icon_image_path and use that for verification.)
A section in the XML for a class can look as follows.
<ClassInfo Name=”FlexAdvancedDataGrid” GenericTypeID=”table” Extends=”FlexListBase” SupportsTabularData=”true”>
<IconInfo IconFile=”TEAPluginQTP.dll” IconIndex=”207″/>
<Operation ExposureLevel=”CommonUsed” Name=”HeaderShift” PropertyType=”Method”>
<Implementation Class=”mx.events::IndexChangedEvent” Type=”headerShift”/>
<Argument Name=”newIndex” IsMandatory=”true”>
<Description>The zero-based index of the child after the change.</Description>
<Argument Name=”oldIndex” IsMandatory=”true”>
<Description>The zero-based index of the child before the change.</Description>
<Operation Name=”SetFocus” PropertyType=”Method” ExposureLevel=”CommonUsed”>
<Property Name=”allowDragSelection” ForVerification=”true”>
<Description>If true, A flag that indicates whether drag-selection is enabled.</Description>