Background
FlexMonkium or if you prefer FlexMonkey as well as QTP recognizes the objects using their unique properties (automationname, id, etc…). Some of flex objects get the automationname from labels property (e.g. button) which is fine as you won’t have identically labeled buttons (at least you should not). Avoid using dynamically generated properties (e.g. automationindex). This for sure will lead to many problems in terms of automation.
Before starting the automation we will need to configure application to allow automation tool to recognize the flex objects. There are several libraries that have to be compiled into your *.swf files. It’s also worth including additional object properties recognition tool. I’ve experienced several times the situation where FlexMonkium Console displayed incorrect property value.
The post treats about configuration setup for flex 3.5, however there should not be much differences with older/newer versions.
FlexMonkium Console/Selenium IDE installation
Refer to FlexMonkium/Selenium IDE installation guide
Building application
Download the files from below:
- Automation_monkey.swc library (free registration)
- Adobe automation swc’s which resides in “libs” of the FlexBuilder
-required: automation.swc, automation_agent.swc
-optional: automation_rb.swc, automation_agent_rb.swc,
datavisualization.swc, datavisualization_rb.swc,
automation_dmv.swc
- Additional objects spying tool (FlexSpy)
- Flex SDK configuration file (guide)
- Command Line Compiler (guide)
- Flex Builder project settings (guide)
- Maven with flexmojos plugin (see below)
Note: Standard Flash Builder edition will limit your playback and recording actions. To avoid popup notification "License not present. With Trial version only limited records are allowed" use the licensce key from Professional Flash Builder (guide).
FlexSpy configuration
To make FlexSpy window appear in your application, some "extra" code has to be added to your application. Choose one method::
- add launch button (guide)
- keyboard event (eg. ctrl + F9)
Most of the projects probable use maven as a build system. In such case pom.xml requires some changes to include automation libraries and license.As for automation purposes we need to include extra libraries, it's good idea to make the build configurable. By adding simple flag while building the application you may/or not include automation libraries. You may think about the profiles as the way of parametrization of the build process.
We will create three profiles for flexspy, Adobe automation libraries, FlexMonkey.
Add following section to main properties (/project/properties) of the project:
<flexspy-included-lib />
<flexmonkey-included-lib />
Now let's create three profile under /project/profiles section.
FlexSpy:
<profile>
<id>flexspy</id>
<dependencies>
<dependency>
<groupId>setGroupReflectingDomain</groupId>
<artifactId>flexspy</artifactId>
<type>swc</type>
<version>putVersionHere</version>
</dependency>
</dependencies>
<properties>
<flexspy-included-lib>
com.flexspy.FlexSpy
</flexspy-included-lib>
</properties>
</profile>FlexMonkey:<profile>
<id>flexmonkey</id>
<dependencies>
<dependency>
<groupId>setGroupReflectingDomain</groupId>
<artifactId>flexmonkey</artifactId>
<version>4.1.6</version>
<type>swc</type>
</dependency>
</dependencies>
<properties>
<flexmonkey-included-lib>
com.gorillalogic.flexmonkium.FlexMonkium
</flexmonkey-included-lib>
</properties>
</profile>Adobe autoamtions swcs:<profile>
<id>adobeautomation</id>
<dependencies>
<dependency>
<groupId>setGroupReflectingDomain</groupId>
<artifactId>automation</artifactId>
<version>putVersionHere</version>
<type>swc</type>
<scope>internal</scope>
</dependency>
<dependency>
<groupId>setGroupReflectingDomain</groupId>
<artifactId>automation_agent</artifactId>
<version>putVersionHere</version>
<type>swc</type>
<scope>internal</scope>
</dependency>
<dependency>
<groupId>setGroupReflectingDomain</groupId>
<artifactId>automation_rb</artifactId>
<version>putVersionHere</version>
<type>swc</type>
<scope>internal</scope>
</dependency>
<dependency>
<groupId>setGroupReflectingDomain</groupId>
<artifactId>automation_agent_rb</artifactId>
<version>putVersionHere</version>
<type>swc</type>
<scope>internal</scope>
</dependency>
<dependency>
<groupId>setGroupReflectingDomain</groupId>
<artifactId>datavisualization</artifactId>
<version>putVersionHere</version>
<type>swc</type>
<scope>internal</scope>
</dependency>
<dependency>
<groupId>setGroupReflectingDomain</groupId>
<artifactId>datavisualization_rb</artifactId>
<version>putVersionHere</version>
<type>swc</type>
<scope>internal</scope>
</dependency>
<dependency>
<groupId>setGroupReflectingDomain</groupId>
<artifactId>automation_dmv</artifactId>
<version>putVersionHere</version>
<type>swc</type>
<scope>internal</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>setGroupReflectingDomain</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>putFlexMojosVersionHere</version>
<extensions>true</extensions>
<configuration>
<licenses>
<flexbuilder3>
putFlexLicenseHere
</flexbuilder3>
</licenses>
</configuration>
<dependencies>
<dependency>
<groupId>com.adobe.flex</groupId>
<artifactId>compiler</artifactId>
<version>putVersionHere</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.adobe.flex.compiler</groupId>
<artifactId>license</artifactId>
<version>putVersionHere</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
Read about naming convention for groupID, artifactID, version.
Once pom.xml has been updated, let's build application using automation profiles:
mvn install -Padobeautomation,flexmonkey,flexspy
Configuration validation
Assuming you've managed to build your project it's high time validating it.
- Open your application
- Start FlexMonkium Console (you may use the FlexMonkium Console button from Selenium IDE)
- Once flex application has been loaded, monkey connection indicator should get green (see screenshot) -you are now connected !!!
VoilĂ !
Coming next: FlexMonkey Commands and Actions