Discussing the nuts and bolts of software development

Tuesday, March 02, 2010


RIATest: Automating Custom Components

RIATest is a GUI test automation tool for Adobe Flex applications. RIATest does for your GUI what FlexUnit does for your code, and it is available on Windows and Mac OS X. RIATest has number of useful features which can be very helpful, such as component inspector, script debugger, and synchronization capabilities. You can find the full list of features here.

When you specify actions that must be performed on your application the first thing you specify is what component you want to be located by RIATest so that an action can be performed on it. RIATest has few ways of locating components. One of the ways is locating component by label e.g. button with "Save" label can be located following way:


Component can be located in a same manner using components automatationName. You can also locate component using its automationIndex:


In most of the cases you are getting every component which you need in the inspector, so you can easily locate those components. In case you derive a custom class from built-in container-type classes you usually do not need to do anything special to make children of your custom component available for automation since this is done by the automation delegate of base class.

However sometimes you implement a custom component that contains other components but your custom component is not derived from Container built-in class. If that is the case you need to expose components contained in your custom class. You will need to perform some additional steps to access them.

Let's discuss one exact example. Here we have a CustomPanel with a button added in its title bar. You will notice that the button which you just added is not visible in the inspector:

So what we can do? We need to implement automation delegate class for our custom component. Exposing child components is done by implementing numAutomationChildren/getAutomationChildAt pair of functions. numAutomationChildren function must return the number of children component for your custom class, getAutomationChildAt must return the child at the specified index. This means we need to implement automatation delegate class for our custom component to make Switch button accessible from RIATest.


In our case we will need to return the number of children which are implementing IAutomationObject plus Switch button:
override public function get numAutomationChildren() : int {
    var count:int = 0;
    for(var i:int=0; i < comp.numChildren; i++) {
        if (comp.getChildAt(i) is IAutomationObject)
    return ++count;


getAutomationChildAt will need to return the child with a given index in case of index < numChildren and return Switch button in case of index == numChildren
override public function getAutomationChildAt( index : int ) : IAutomationObject {
    if (index >= 0 && index < comp.numChildren )
        return comp.getChildAt(index) as IAutomationObject;
    if(index == comp.numChildren)
        return comp.button;
    return null;

We will also need to implement init method in order to register our delegate class:
public static function init( root : DisplayObject ) : void {
    Automation.registerDelegateClass( CustomPanel, CustomPanelAutomationImpl);

The only thing left to do is to include our delegate into build, include your delegate class using additional compiler arguments:

-includes CustomPanelAutomationImpl

As you can see from the screenshot now Switch button is getting displayed in the inspector, so you can easily locate it:


You can download source code of this project from here.

Can you tell me if i must declare class infos in the classinfo file located in Riatest sub directory?

Thank you very much.
Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..
Android Training in Chennai
Ios Training in Chennai

If you want to know more about android hacks, https://cellspyapps.org/android-hacks/ will help you. I know it for sure.
This comment has been removed by the author.
Get the My Assignment Help Australia services at very cheap rates.
The composers of the Custom Economics Paper Writing Services are the leading ones in the industry as they give high quality Custom Economics Essay Writing Service and they assure originality of their Professional Economics Paper Writing Service.

Law Assignment Writing Services are hard to come across for those in need of Law Research Writing Services and law essay writing services.

Finding the best healthcare assignment writing services and Medical Assignment Writing Services is not easy unless one is keen to establish a reliable custom medical research paper provider & medical writing service help online.

It is very useful and top articles and I love this article. Some articles have no longer following the best however right here I new way of writing. captain marvel jacket
We're searching for web givers with a composing foundation who are energetic in carrying on with a real existence injected with the healthy and hand crafted love of farmhouse way of life to Write for us Technology. What does it take to be a web supporter? We have our eyes out for individuals who have their finger immovably on the beat.
RIATest is a very useful and effective application for getting help in the component inspector, script debugger, and synchronization capabilities. I always used to this application due to its latest and good features. Its performance is exceedingly good and it is available on Windows and Mac OS X. Essay Writing Services

Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?