Custom component Automation – Introduction
September 1, 2009 at 7:05 am
Since Flex allows the users to have custom controls, to have the complete automated testing support of the application which uses those controls, there may be necessity for providing an extended support for the same also. i.e when a user creates a custom control, there may be a need for custom delegate also.
Before we look into the custom component and automation of the same, let us try to understand the automation work flow.
Notes:
- Here I am not covering the steps to create the custom delegate.
- The purpose of this section is to uderstand the flow of information and the role of the delegate.
- And for the concepts to be clear I am addressing only events (user interaction ) as the criteria here. In the advanced sections, we shall cover more on the other details like additional properties, additional methods etc.)
Automation steps. (The section covers the usage of delegate, eventhough it is possible to add the details in the control itself.)
Recording:
1. Identify the events to automate.
2. Delegate listen to these events, and get the details of the events, which is needed to replay the event later.
3. Pass the details collected to the Automation Manager. Automation Manager dispatches an event with these details and the tool libraries will listen to it, process it and record it.
Replay:
1. Tool will send the replay information to the tool library.
2. Tool library will process the information recieved, crete the object specific event, and call method on the Automation Manager API.
3. Automation manager will call appropriate methods on the component/delegate.
The above picture shows the elements involved in the total work flow. So as per the picture we can see that, there is one delegate for one component. So when we add a new component, we may need to provide a new delegate.
Please note that ‘we may need to ‘ not that ‘we should’.
Now let us see when we need the delegate and when we dont.
What is a custom component ?
Let us take the following cases and analyse each in detail.
‘Case 1: Composite control. i.e a custom control made of existing framework components. Let us take the example of a login control which is made up of some form items, button etc. So here it is a custom control as the user would have intended to use this control in many places and in many applicaitons. So for easy reuse the a custom component is made. In this case do we need a custom delegte ? In most of the cases No. Why? The controls used are existing framework controls. E,g the container would have been a panel or canvas? So that knows how to gets its childern. The elements used would have been TextInput , button etc. These components know how to handle the user interaction on them and how to record.
For this component also we may decide to go for a delegate . When ? When we want events specific to the controls. What does it mean?
When we use the standard framework delegates for the above case, the components and the events will not be specific to the Login page.
e.g If the user enters name in the textInput with id ‘name’ the script shall look as follows.
Browser(“xxx”). Application(“yyyy”).Panel(“aaa”).TextInput(“name”).input MyName
So here the event will not look specific to the Login control.
Assume the user wants the event to look like
Browser(“xxxx”).Application(“yyyy”).LoginControl(“logid”).NameInput MyName , we need a custom delegate to handle this.
Case 2: Extending an existing automation enabled control. i.e assume the user wants to customize an existing control to add new functionalities or customize existing functionalities of the same. In this case, do we need a custom delegate ? The answer is based on the the purpose of the new component. e.g let us assume that there are no new user inteaction possibilities or no new custom events from that component which is the result of a user interaction. In this case, we dont need to do anything. The delegate of the basic component will take care of the record and replay of the existing events on this control.
Assume that user has new events which needs to be recorded other than the existing events on the base component or user wishes to have new events instead of the events on the base component to be recorded, we need to have a custom delegate. Note, the user need to have the custom delegate extending from the base component delegate.
i,e assume the custom component is extending from AdvancedDataGrid and the custom delegate for this component should extend from AdvancedDataGridAutomationImpl, so that all other events on the base compoent will be handled by its delegate.
Case 3 : Creating a control from UIComponent.
Assume user is creating a fresh control from the UIComponent. The component may be a container or a simple control. Whatever the type may be, to have the user interction recordable and replayable we need a custom delegte.
How to write custom delegate for the above 3 cases ? Refer the FlexBuilder/FlashBuilder help on the same, till I have my next blog ready.
Entry filed under: Flex Automation, Flex Automation.
1. Henry | November 13, 2009 at 3:00 am
Great article!! Is there any RSS can follow up?
Thanks a lot.
2. Ashley | February 21, 2010 at 5:12 pm
I am newbie to flex as well as QTP automation. I am trying to automate CanvasButtonAccordionHeader from flexlib but I am not able to automate the mouse over effect as shown on http://dougmccune.com/blog/2007/09/22/nifty-flex-accordion-menu-like-on-applecom/. Could you please help me?
3. raniskumar | April 13, 2010 at 1:09 pm
check out https://raniskumar.wordpress.com/2009/09/10/automating-mouse-move/
4. raniskumar | March 22, 2010 at 6:07 am
I am sorry that i could not get time to get the fruther parts of this topic here. Since many people are interesterd in samples, i am attaching a presenation and some samples