Showing posts with label flex. Show all posts
Showing posts with label flex. Show all posts

Sunday, April 19, 2009

Flex automation testing with QTP

QTP can be used to test the Flex application. You need to perform following steps to setup recording a flex application with qtp.

  1. Install QTP 9.2
  2. Install Internet Explorer
  3. Install flash player debug version for IE
  4. Install Flex Builder 3
  5. Install QTP plugin of flex from FLEX_BUILDER3/Installers/QTP_Plugin_Installer
  6. Compile your flex application with automation libraries. It can be done in two ways; either use -include-libraries parameter in Flex Builder3 or use mxmlc ant task. This step is must otherwise QTP will not recognize the flex application
  7. To record a test in QTP, you must compile the application’s SWF file and generate the HTML wrapper files. The main wrapper file defines the application as an object on the page and embeds it so that Flash Player is invoked when the page is requested. You cannot request the application’s SWF file directly. You can write the HTML wrapper yourself, or generate it with the compiler.
  8. Start QTP
  9. QTP wil show the all plugins on startup, select the flex plugin and continue
  10. Start recording for your flex application.

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"/>

Wednesday, April 15, 2009

Use JMeter to load test FLEX Applications

Flex applications use a binary protocol called AMF (Action Message Format) that they use to remotely communicate with the server. The easiest way to use JMeter with a Flex application is to use HTTP proxy server.

- Create a New Test Plan
- Right Click on Test Plan, Add -> Thread Group
- Right Click on Thread Group, Add -> Config Element -> HTTP Request Defaults
- Select 'HTTP Request Defaults'
- Specify Server Name or IP, for eg. www.mysite.com
- Specify Port number, eg. 8888
- Specify protocol, i.e. http
- Specify Path, foe eg. /main/index.html
- Select Work Bench
- Right Click on Work bench, Add -> Non-Test Elements -> HTTP Proxy Server
- Select 'HTTP Proxy Server'
- Specify port number for proxy (default is 8080)
- Set Target Controller to 'Test Plan -> Thread Group'
- Set inlude URL patterns , .* to include all
- Set exclude URL patterns, for eg. , .*\.gif, .*\.png, .*\.css, .*\.js
- Open Internet Explorer
- Goto Tools -> Internet Options -> Connections -> LAN settings
- In Proxy Server panel, specify address as 'localhost' and port number (which is specified in
meter's HTTP proxy server, i.e. 8080)

- Select 'HTTP Proxy Server'
- Click on Start
- Open IE and open URL 'http://www.mysite.com:8888/main/index.html'
- As soon as you visit the URL jmeter starts the recording, and you can see all the requests in
METER

- For AMF requests (for Adobe FLEX), request is saved as file with extension '.binary' in the bin
irectory of jmeter

- Click on Stop button of 'HTTP Proxy Server' to stop the recording.

Test Plan is ready. You can modify it now according to your requirements.

Proxy Server setup document from Apache:
http://jakarta.apache.org/jmeter/usermanual/jmeter_proxy_step_by_step.pdf