info

Make your flex tests automated, make them run nightly, no more manual tests ...

Wednesday, May 25, 2011

Environment configuration

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

Note: Install the items from guide regarding FlexMonkium/Selenium and leave those parts about swc compilation.


Building application

Download the files from below:
  • 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)
Once you will gather all swc libraries you will need to compile them into your swf file. There are several possible ways to achieve that goal depending on your build procedure.
  • Flex SDK configuration file (guide)
  • Command Line Compiler (guide)
  • Flex Builder project settings (guide)
  • Maven with flexmojos plugin (see below)
Note: Remember also to include flex monkey swc that corresponds to your Flex SDK version and optionally flexspy.swc

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)
Maven with flexmojos configuration
    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.
  1. Open your application
  2. Start FlexMonkium Console (you may use the FlexMonkium Console button from Selenium IDE)
  3. 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

Monday, May 16, 2011

Let's start

What's the purpose of this blog?
You may think about this blog as a practical guide (hope so) to help you with your test automation and make your life much easier.
Some time ago I was challenged with the same "problem". Flex(currently Flash) is a poorly supported in terms of test automation.
So which technology should we use ?
Several years ago there was no much options, actually in that time there was only one potential tool - QTP (see below). After several (or more) unsleepy nights decision was mode - tests are unmanageable.
A lot of time was spent to find out the best tool to achieve the goal - continues integration, stability.
FlexMonkey seems to bring most valuable automation background.


Why FlexMonkey?
As mentioned before, it took a while to choose the automation framework, and incoming(that time) change was also to get rid of QTP because of several reasons(those of you that are using QTP knows what I'm talking about :))

- stability (QTP does not provide built-in Flex plug-in, it comes from Adobe)
- has to be run under Windows env.
- execution time of flex tests was a disappointment
- representation of test objects
- VisualBasic programming language (sorry, I simply don't like it)
- poor editor/poor debugger
- ...

FlexMonkey resolves all above issues. With Selenium RC and one of companion programming languages (Java, Ruby, Php, Python, Perl, .Net) it has occurred to be the best tool on market, and yes this is open source(GNU license).


What kind of information you may find in incoming posts?

It's all about flex automation with FlexMonkey including continues integration, build system and tests management.


 Overview:
  • environment configuration (Eclipse IDE/Selenium IDE/Selenium RC/Flex Monkium)
  • flex monkey commands description
  • flex monkey actions descriptions
  • flex monkey commands synchronizations
  • flex monkey issues solving
  • make your life easier - flex monkey commands wrapper
  • java examples
  • managing your tests with TestNG
  • continues integration with Hudson/Jenkins
  • building your tests with maven
  • and much more ...