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.
- 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).
- Copy automation tool library (qtp.swc in case if you are using QTP as testing tool) in C:\flex-automation
- 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.
- Copy FLEX_HOME/frameworks/flex-config.xml to flex-config-auto.xml and keep it in same directory (FLEX_HOME/frameworks)
- Add following entries in include-libraries section of flex-config-auto.xml
- <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> - In mxmlc task of ant build file specify load-config path as
- <load-config filename="FLEX_HOME/frameworks/flex-config-auto.xml"/>
- Add compiler-library-path in mxmlc task
- <compiler.library-path dir="C:/flex-automation" append="true">
<include name="locale/en_US" />
</compiler.library-path>
<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_/

