Flex application Automation Using QTP
There are two approaches to enable Flex application automation using QTP.
Runtime Approach.
Compilation Approach.
Runtime Approach:
General Implementation Concept:
You use the run-time testing files rather than building your applications with testing libraries. This lets you test SWF files that are compiled without automated testing support. To do this, you use a SWF file that does include the automated testing libraries. In that SWF file, the SWF Loader class loads your application's SWF file which does not include the testing libraries. The result is that you can test the target SWF file in a testing tool such as QTP, even though the application SWF file was not complied with automated testing support.
Flex Builder includes a wrapper SWF file and an HTML template that supports run-time loading. The source MXML file for the wrapper SWF file is also included. The following files are located in the “Flex_builder_install_dir/sdks\3.2.0\templates\automation-runtimeloading-files”
RunTimeLoading.html -- The HTML template that loads the run-time loader SWF file. This template includes code that converts the automationswfurl query string parameter to a flashVars variable that it passes to the application. You use this query string parameter to specify the name of the application you want to test.
runtimeloading.mxml -- The source code for the runtimeloading.swf file that you compile. The SWF file acts as a wrapper for your application. This SWF file includes the testing libraries so that you do not have to compile them into your application SWF file.
Compile the runtimeloading.swf file: You can use the batch file in the Flex_builder_install_dir/sdks\3.2.0\templates\automation-runtimeloading-files directory. Execute this batch file from the sdks/3.2.0/frameworks directory. This batch file ensures that your runtimeloading.swf file includes the automation.swc, automation_agent.swc, automation_dmv.swc, automation_flashflexkit.swc, and qtp.swc libraries.
Deploy the runtimeloading.swf, RunTimeLoading.html, and your application's SWF file to a web server. Request the RunTimeLoading.html file and pass the name of your SWF file as the value to the automationswfurl query string parameter.
For example: http://localhost/RunTimeLoading.html?automationswfurl=MyApp.swf
Implementation:
Please find the below steps followed to implement runtime approach.
Steps
Installed Flex builder 3.20 professional version.
Navigated to Flex_builder_install_dir/sdks\3.2.0\templates\automation-runtimeloading-files directory.
Observed that there one wrapper html file RunTimeLoading.html ,RunTimeLoading.mxml file and also build.bat.
We can use the batch file to compile RunTimeLoading.mxml with automation libraries.
After compilation it will generate runtimeloading.swf file in the same directory.
Request the RunTimeLoading.html file and pass the name of your SWF file as the value to the automationswfurl Automationswfurl=application.swf
Copy the runtimeloading.swf, RunTimeLoading.html, and your application's SWF file to a web server.
Compilation Approach:
If you do not use run-time testing, you must compile applications that you plan to test with the testing libraries. The functional testing classes are embedded in the application at compile time, and the application typically has no external dependencies for automated testing at run time.
Implementation of Compilation Approach:
Steps:
Copy the qtp.swc, automation_agent.swc, automation.swc and automation_dmv.swc files from the flex_automation_installer/frameworks/libs directory to flex_sdk_dir/frameworks/libs.
Need to copy the following files (airframework_rb.swc,automation_agent_rb.swc,automation_rb.swc,datavisualization_rb.swc,framework_rb.swc, rpc_rb.swc to) C:\Devtools\flex_sdk_3.3.0.4852\frameworks\libs\locale from flex_automation_installer/frameworks/libs directory to flex_sdk_dir/frameworks/libs
Implementation:
We have the added the above said tag to mxml target in ux/ant/compile.xml and compiled the application.mxml,Please refer the compile.xml from section 49 to 75
The modified ant target will be as follows.