Custom component Automation – Part III – Container class extending from non container class

April 12, 2010 at 8:50 am 13 comments




Custom Component automation presentation


  •  read the part I session on custom component automation.…n-introduction

 read the part II session on custom component automation.

Custom component automation  – Container class extending from non container class

In this post I would try to explain the steps to be followed for handling the case of  a custom class which was extending from a non standard container class, but the class need to be treated as the container class.

e.g Your custom class MyClass extending from UIComponent (which is a non container standard framework class), eventhough as  a standard class it does not represent a container, it allows  to use the class as container programatically by using addChild, getChild etc. 

So if your extended class is meant to be a contianer (i,e if you woud like to get the children objects what you added in your base class), you need to program for the same.   The section explains how you can expose your children so that the user interaction on  those components can be supported. (e.g a button inside your contianer . Your script should look like

Application …… MyClass. childButton .click

i.e this sample does not cover how to expose events and user interaction on the MyClass. it coveres how the script can access the childButton in MyClass


  • Have your class MyClassAutomationImpl extend from UIComponentAutomationImpl
    • Refer the constructor and init in the sample delegate


  • Override the following methods (Note sample are only to explain the concept. It would not have followed all coding conventions)
    •  numAutomationChildren  – this method should have the logic to find the number of children in the component and return. If your component is a fixed element contianer you can provide this detials. If your component is a container to the user and number of children is based on usage, this need to be computed and returned. (for calculation logic samples refer application)         

               override public function get numAutomationChildren():int{return 2;}


    • getAutomationChildren  – return children – calculated and or known.

 override public function getAutomationChildren():Array{

var childrenArray:Array = new Array();



return childrenArray;


    • getAutomationChildAt- return children – calculated and or known.

override public function getAutomationChildAt(index:int):IAutomationObject{

if(index ==0)

return customContainer.button1;

else if (index ==1)

return customContainer.button1;


return null;


    • createAutomationIDPart- create the part information of the child. Automation framework already has the logic of calculating this.  This internally uses the automationName and automationIndex to calutate this. However if you have a separate logic for calculating these, you can pass your callback methods here. Else, simply copy pase the following lines.

override public function createAutomationIDPart(child:IAutomationObject):Object{

var help:IAutomationObjectHelper = Automation.automationObjectHelper;

return help.helpCreateIDPart(uiAutomationObject, child);


    •   createAutomationIDPartWithRequiredProperties– create the part information of the child only using the requried properties as part of the part object.  This internally uses the automationName and automationIndex to calutate this. However if you have a separate logic for calculating these, you can pass your callback methods here. Else, simply copy pase the following lines.

 override public function createAutomationIDPartWithRequiredProperties(child:IAutomationObject, properties:Array):Object{

var help:IAutomationObjectHelper = Automation.automationObjectHelper;

return help.helpCreateIDPartWithRequiredProperties(uiAutomationObject, child,properties);


    •   resolveAutomationIDPart– find the object using the part information.  This internally uses the automationName and automationIndex to calutate this. However if you have a separate logic for calculating these, you can pass your callback methods here. Else, simply copy pase the following lines.

 override public function resolveAutomationIDPart(part:Object):Array{

var help:IAutomationObjectHelper = Automation.automationObjectHelper;

return help.helpResolveIDPart(uiAutomationObject, part);


Have the entry for this class in the xml file.  For that you can do the follow.

  • Get the section of the base class entry in the existing xml file.
  • Copy the contents, change the details as appropriate
  • e.g
    <ClassInfo Name=”MyClass” GenericTypeID=”table” Extends=”FlexObject” SupportsTabularData=”false”>

<IconInfo IconFile=”TEAPluginQTP.dll” IconIndex=”207″/>


<Implementation Class=”mx.controls::MyClass”/>



Entry filed under: Flex Automation. Tags: , .

Custom component Automation – Part II Record replay works , but other features of QTP such as object spy, hightlight in application does not work?

13 Comments Add your own

  • […] Custom component Automation – Part III – Container class extending from non container cl…  |  April 12, 2010 at 9:11 […]

  • 2. Nekobasu  |  July 8, 2010 at 4:08 pm

    Even for this extremely simple example, Flash Builder gets an error when overrriding getAutomationChildren:

    package myPackage;

    import mx.automation.delegates.core.UIComponentAutomationImpl;
    import mx.core.mx_internal;

    use namespace mx_internal;

    public class myClassAutomationImpl extends UIComponentAutomationImpl
    override public function getAutomationChildren():Array
    return [];

    The error is:
    1020: Method marked override must override another method.

    How do you work around this while still overriding getAutomationChildren?

    • 3. raniskumar  |  April 6, 2011 at 10:04 am

      I think you are using the sdk3 automation.

  • 4. thomas  |  January 12, 2011 at 4:11 pm

    The correct link for prerequisit #1 should be

  • 5. Satguru Saran  |  January 31, 2011 at 2:33 pm


    Can we add a new method OR event OR property to a Standard Flex Component? e.g. Currently “FlexListLabel” does not have any method / event / property that can give us the visible text on the application.

    Awaiting your response.


    • 6. raniskumar  |  February 11, 2011 at 1:11 pm

      you can extend the existing delegate, provide methods in the delegate, mention the method details in the XML and use.

    • 7. raniskumar  |  April 6, 2011 at 9:55 am

      Yes, you can use methods, not properties.
      So what you need to do is as follows. (From Flex 4)
      1. Extend the existing delegate class – use the register delegate method with a higher value than nornal (normal is 0)
      2. Provide the new method in the delegate class
      3. Modify the component section in the xml file to refer to the new method.

      From the testing tool, you would be able to call the new method.

  • 8. Vikash Agarwal  |  May 17, 2011 at 1:56 pm

    Does selenium record and play custom components?

    • 9. raniskumar  |  July 21, 2011 at 12:35 pm

      No idea. If they are using flex automation framework and if you provide necessary information theoritically it should work. Refer the custom component automation posts.

  • 10. Vikash Agarwal  |  May 23, 2011 at 1:27 pm


    I have a custom List, how to write getAutomationChildAt, getAutomationChildren() methods. My Custom List contain Custom item Renderer and each renderer can have children.

    Thanks in Advance

  • 11. Jenny  |  August 3, 2011 at 10:41 pm

    Thank you for this post! I had been trying to solve this problem for days when I found it. It did the trick for my custom component.

    I am now trying to do the same for a custom spark component. I would like to return one of its skin parts as the single child of the component. I have thus far been unsuccessful. I am guessing it has something to do with me not returning the correct values in createAutomationIDPart, createAutomationIDPartWithRequiredProperties, or resolveAutomationIDPart. Or am I going about this all wrong? Any help is greatly appreciated.

    Thanks again.

  • 13. qknguyen  |  March 22, 2012 at 8:41 am

    Hi, can you tell me where i can find the xml file? I am using RIATest 4. I found in the project folder one xml file “_cachedClassInfo” but i wonder if this is correct file or the file in the RIATest installation directory?

    Thanks for your help


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


April 2010
« Dec   Jul »

Most Recent Posts

%d bloggers like this: