Sunday, April 19, 2009

Build FLEX application with automation libraries using Flex3 SDK and ANT

To test Flex Application with any automated testing tool (like QTP), automation libraries should be included in the application SWF file to make the application testable. Flex Automation libraries are not part of the Flex SDK, these comes with Flex Builder 3. If you are using Flex SDK and ANT as build tool, you need to perform following steps to compile your application.

  1. Copy flex automation libraries (automation.swc, automation_agent.swc, automation_dmv.swc, automation_flashflexkit.swc) from Flex Build 3 installation (/frameworks/libs) to your local directory (let say C:\flex-automation).
  2. Copy automation tool library (qtp.swc in case if you are using QTP as testing tool) in C:\flex-automation
  3. Copy flex agents (automation_agent_rb.swc, automation_rb.swc) in C:/flex-automation/locale/en_US. Flex agent facilitates communication between a flex application and an automation tool.
  4. Copy FLEX_HOME/frameworks/flex-config.xml to flex-config-auto.xml and keep it in same directory (FLEX_HOME/frameworks)
  5. Add following entries in include-libraries section of flex-config-auto.xml
  6. <include-libraries>
    <library>C:/flex-automation/automation.swc</library>
    <library>C:/flex-automation/automation_agent.swc</library>
    <library>C:/flex-automation/automation_dmv.swc</library>
    <library>C:/flex-automation/automation_flashflexkit.swc</library>
    <library>C:/flex-automation/qtp.swc</library>
    </include-libraries>
  7. In mxmlc task of ant build file specify load-config path as
  8. <load-config filename="FLEX_HOME/frameworks/flex-config-auto.xml"/>
  9. Add compiler-library-path in mxmlc task
  10. <compiler.library-path dir="C:/flex-automation" append="true">
    <include name="locale/en_US" />
    </compiler.library-path>
so your mxmlc task would look like this:

<mxmlc file="${APP_ROOT}/Main.mxml" output="${build.dir}/main.swf">
<load-config filename="${FLEX_HOME}/frameworks/flex-config-auto.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs" />
<include name="locale/en_US" />
</compiler.library-path>
<compiler.library-path dir="${FLEX_AUTOMATION_HOME}" append="true">
<include name="locale/en_US" />
</compiler.library-path>
</mxmlc>

mxmlc ANT task comes with flexbuilder3 and flex sdk. In flex builder, the location of task is : _FLEX_BUILDER_INSTALL_LOCATION_\sdks\3.0.0\ant\flexTasks.jar

To use this ant task in ant build file use ant taskdef task as below:
< taskdef resource="flexTasks.tasks" classpath="_PATH_TO_TASK_/flexTasks.jar"/>

11 comments:

Naren said...

Hi....

its really a nice info.

But where can i find the ANT task?

I ma using mvn and jetty server.
How can i configure for that?

please help me in this regard.

Thanks,
Naren

Vishnu Agrawal said...

Naren,

ANT task comes with flexbuilder3 and flex sdk.

In flex builder, the location of task is : _FLEX_BUILDER_INSTALL_LOCATION_\sdks\3.0.0\ant\flexTasks.jar

To use this ant task in ant build file use ant taskdef task as below:

<taskdef resource="flexTasks.tasks" classpath="_PATH_TO_TASK_/flexTasks.jar"/>

Vishnu Agrawal said...

Information on this task is available @ http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html

Unknown said...

unable to edit mxmlc class file please provide details on last 5 steps

thank you

Unknown said...

Hi Naren,

I am new to Flex testing with QTP. Can you pls give me whole details how ill go an d test the flex application with QTP. pls mention every step as a Beginner.
Please send me a mail.
Thanks a lot for help.

Thanks,
Monika
monikasri11@gmail.com

Unknown said...

Hi Naren,

I am new to Flex testing with QTP. Can you pls give me whole details how ill go and test the flex application with QTP. pls mention every step as a Beginner.
Please send me an mail.
Thanks a lot for your help in advance.

Thanks,
Murali
konijeti2@gmail.com

Neerajkumar said...

Hi,

Can i run ANT in GUI Mode... like while Jmeter start running..

I want to generate graph.. so i'm asking it..

Any suggestion..?

Thanks
Neerajkumar

Vishnu Agrawal said...

Hi Neeraj,

I am not clear with your question. Do you mean to run ANT by Jmeter UI.

-Vishnu

Neerajkumar said...

Hi Vishnu,

Thanks for your reply

Yes,

When i run JMeter, i should get ANT report (HTML) with Jmeter's Graph also.

Thanks,
Neerajkumar

Napster said...

Hi Naren,

I am new to Flex testing with QTP. Can you pls give me whole details how ill go and test the flex application with QTP. pls mention every step as a Beginner.
Please send me an mail.
Thanks a lot for your help in advance.

Thanks,
Pavan
pavan790@gmail.com

Napster said...

and what if the flex application is in a link (web page) how could i automate
Please help.
Note: I'm using UFT 11.5