The
Flash/Flex Test Automation Plugin (for Windows Internet Explorer and Firefox) provides
a smooth integration with the Ranorex Automation Framework and its
tools. You can easily filter, access and validate Flex controls easily
using RanoreXPath. You have full access to all the properties and attributes of Flash and Flex elements.
Test Automation of Flash/Flex controls with Ranorex
The architecture of a Flash/Flex object is easy to see within Ranorex Spy. All embedded Flash or Flex elements are shown as a Flex node in the tree view.
Use Ranorex Recorder to automate Flash/Flex applications in Internet Explorer and Firefox. You can add user code actions to your recordings to access custom Flex properties.
How to read/set attributes and styles
You can read/set common attributes (e.g. the checkstate of a checkbox) directly by using the adaptor as follows:
// Set the checked state with the property "Checked"
repo.FlexTestPageDom.CheckBox_Control_Example.CheckBoxEggs.Checked = true;
To access custom attributes and styles, you first have to load your Flex item as a FlexElement in order to read your attributes. Here's an example:
// Load the slider as a Flex element to access flex attributes
FlexElement sliderFlex = repo.FlexTestPageDom.ContainerHSlider_Control.SliderHSlider.As<FlexElement>();
sliderFlex["value"] = "100";
FlexElement containerFlex = repo.FlexTestPageDom.Self.FindSingle(".//container[@caption='Tree Control']");
containerFlex.SetStyle("borderColor","#ee0000");
Using the Ranorex Loader
The RanorexLoader enables automation of your flash/flex application without including the automation lib directly into your application.
- Copy the RanorexLoader.swf file (located in the Bin directory of your Ranorex installation) to your web server (where your .swf file is located)
- Open Internet Explorer or Firefox with following url and set the “rxtarget” parameter to your flash file as follows:
"http://www.yourserver.com/RanorexLoader.swf?rxtarget=yourflash.swf"
or
"file:///C:/.../RanorexLoader.swf?rxtarget=yourflash.swf"
Adobe Flex: Load the Ranorex Lib into your Flex application
- Start Adobe Flex Builder and open your workspace
- Right-click on your project and choose Properties
- Under Flex Compiler add the Ranorex.swc file (located in the Bin directory of your Ranorex installation) to the the compiler argument as follows:
-include-libraries "C:\Program Files\Ranorex 2.1\Bin\Ranorex.swc"
- Save and compile your application
- Run your application in Internet Explorer or Firefox
- If you run your Flex application from the local drive, add your output directory to the trusted locations of Flash Player as follows:
- Open following link
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html#119065 - Add your project output directory
Adobe Flash: Load the Ranorex Lib into your Flash application
- Start Adobe Flash CS4 and open your application
- Open the "Publish Settings" dialog (File->Publish Settings)
- Include the Ranorex Flash Library in your Flash application under Flash->Script->Settings...->Library Path and choose "Browse to SWC file"
- Select "Ranorex.swc" file in the browse dialog (Ranorex.swc is located in the Bin directory of your Ranorex installation)
- Insert following code to your ACTIONS:
import Ranorex.RxAutomation;
RxAutomation.InitFromApp(stage);
OR add the code to your ActionScript source file as follows:
import mx.controls.*;
import flash.events.*;
import flash.display.*;
import flash.ui.Keyboard;
import flash.geom.Rectangle;
import fl.events.SliderEvent;
// Add Ranorex library
import Ranorex.RxAutomation;
public class Simple extends MovieClip
{
public function Simple()
{
// Add to your constructor
RxAutomation.InitFromApp(stage);
}
}
- Run your application in Internet Explorer or Firefox
- If you run your Flash application from the local drive, add your output directory to the trusted locations of Flash Player as follows:
- Open following link
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html#119065 - Add your project output directory