FlexMonkium is a bridge between FlexMonkey and Selenium that enables creating and running FlexMonkey test cases through the Selenium IDE. With Flex recording seamlessly interleaved with native Selenium recording and playback you can now easily deal with hybrid testing scenarios, where you have both Flex components and native browser functionality (HTML, CSS, JavaScript) in your web application. In addition to creating and running hybrid test scripts inside the Selenium IDE, you can also use the export feature to generate Java JUnit 4 tests that can be run with Selenium-RC. Using the exported hybrid test scripts and Selenium-RC, it is easy to implement fully automated testing and continuous integration.
Checkout from the svn repository at https://svn.gorillalogic.com/svn/flexmonkey. Use your Gorilla Logic userid to access.
FlexMonkium is comprised of 3 projects:
FireFoxPlugin - The Se-IDE plugin. You can also find user-extensions.js here.
AirMonkey - The AIR/Flex mini-console launched from Se-IDE. This project also includes the full FlexMonkey console.
MonkeyLink - The source for automation_monkiey.swc
See the FlexMonkey documentation for info about building automation_monkey.swc.
Note: FlexMonkium has been compiled and tested with Flex SDK versions 3.2 and later.
In addition to the zip file, you will also need the FlexMonkey zip file.
-includes-libraries libs/automation_monkey.swc
Be sure to use the name of the automation_monkey.swc that corresponds to your Flex SDK version. If for example you were using Flex 4.1, you would specify
-include-libraries libs/automation_monkey.4.x.swc
Selenium IDE is launched from the Firefox Tools menu. If everything is installed properly, there will be a gorilla icon on the Selenium toolbar.
![]()
When you click on the FlexMonkey icon, the FlexMonkiumConsole should appear:

If the console does not appear, select Options > FlexMonkium... from the Selenium menu, click on the Browse... button and navigate to where you installed the FlexMonkiumConsole executable.
Tip: You may sometimes find it convenient to open Selenium as a sidebar rather than a separate window by selecting View > Sidebar > Selenium IDE from the Firefox menu.

FlexMonkium is a plugin for Selenium that adds FlexMonkey recording and playback to Selenium-IDE and Selenium-RC.
Install FlexMonkium by following the instructions in FlexMonkey Setup.
FlexMonkium consists four components:
Instead of for automaton_monkeyN.x., substitute the name of the swc you are actually using, for example automation_monkey4.x.swc.
he above arguments link in FlexMonkium as well as the Flex Automation libraries. Flex Builder automatically sets ${flexlib} to point to your default Flex SDK.
FlexMonkium works mostly seamlessly with Selenium-IDE, interleaving Flex recording and playback with Selenium’s usual browser recording. To learn more about Selenium-IDE, see the Selenium-IDE User Guide.
Simply open the Selenium-IDE window and turn on recording. In addition to the usual browser commands, Selenium will also record Flex commands from any Flex SWF which has been linked with the required libraries.
Each action recorded will create a waitForFlexMonkey command in Selenium-IDE.
Note: The current version of FlexMonkium does not work with pages containing more than one SWF.
Whenever a SWF loads, Selenium will record a waitForFlexMonkey command, which at playback time will pause the script until the SWF loads.
Playback works like usual Selenium playback.
All Flex UI interactions will be recorded as Selenium waitForFlexMonkey commands. The command locator will contain an XML representation of a FlexMonkey command corresponding to the recorded user interaction. The general form of the XML is:
<UIEvent command="commandName" prop="propertyName" value="propertyValue" />
commandName is the name of the command to be executed.
propertyName is the name of a property to use to identify the component being recorded. By default, the propertyName is automationName.
value is the property value used to identify the component.
The following is an example of a command specifying to click on a button labeled "Add".
<UIEvent command="click" value="add"/>
Any prop/value pair can be used to identify a component. The following specifies a click on the component with tooltip="Show details".
<UIEvent command="click" prop="toolTip" value="Show details"/>
To learn more about FlexMonkey commands, see the FlexMonkey documentation.
To open the FlexMonkium console, click on the FlexMonkium icon on the Selenium-IDE toolbar.
The console contains three icons: Create Verify, Connection Status, and Help.
.jpg)
The Connection Status icon will be green whenever a FlexMonkium-enabled SWF is loaded in the current browser page, and will be yellow otherwise.
Note: In the current version of FlexMonkium, recording and playback will not work properly if more than one FlexMonkium-enabled SWF is running during recording or playback. Ensure that only one SWF is running in the current page, and that no other SWF’s are running in other browser windows or tabs.
Click on the Verify icon in the FlexMonkium console to switch to snapshot mode. Click on the browsers title bar, and then mousing over a SWF will highlight underlying components. Click to select a component for which you want to verify some value. A window will open where you can select attributes to be verified. For more information about FlexMonkey verify commands, see the FlexMonkey User Guide.
When you create a Verify command, Selenium-IDE records a waitForFlexMonkey command. The locator will contain an XML-encoded FlexMonkey VerifyProperty command with the following general form:
<VerifyProperty prop="propertyName" value="propertyValue" propertyString="propertyPath" expectedValue="valueExpected"/>
propertyName and propertyValue identify the component to be verified. See the discussion of recorded commands above to learn more about component identification.
propertyPath is a property name or path expression whose value is to be verified.
valueExpected is the value expected for the specified propertyPath.
Note: Prior to FlexMonkium 4.1.4, verifications were recorded as Verify instead of VerifyProperty commands. Beginning with FlexMonkium 4.1.4, VerifyProperty commands were recorded instead because there easier to read and edit, and because they allow verification of property path expressions in addition to simply property names.
The following command checks that the field with automationName="FirstName" contains the value "Fred" for its text property.
<VerifyProperty value="FirstName" propertyString="text" expectedValue="Fred/>
In the above, the prop attribute was omitt not need to be explicitly specified, since it defaults to automationName.
The following command checks that a DataGrid with automationName="SomeGrid" contains five rows (by checking the length of the associated dataProvider):
<VerifyProperty value="SomeGrid" propertyString="dataProvider.length" expectedValue="5"/>
Note: FlexMonkey bitmap verification is currently unavailable in FlexMonkium.
By default, FlexMonkey records a waitForFlexMonkey Selenium command for each recorded user action or verification step. If you do not want to wait, but instead want the command to fail if it's not true on the first try, use the flexMonkey Selenium command instead of the waitForFlexMonkey command.
For VerifyProperty commands, Selenium will wait until the specified condition becomes true, or until a timeout occurs. For UIEvent commands, Selenium will wait until the specified component appears in the application.
At playback time, waitForFlexMonkey commands will be handled like any other Selenium waitFor command, with playback pausing until the condition becomes true, or until a timeout occurs.
Use the getFlexMonkeyValue Selenium command to retrieve property and grid cell values from your Flex app under test.
Note: Prior to FlexMonkium 4.1.4, the getFlexMokeyCellValue command was used to retrieve grid cell values. Beginning with FlexMonkium 4.1.4, getFlexMonkeyCellValue is deprecated, and getFlexMokeyValue is used for both property and cell values.
You can "bootstrap" the creation of a getFlexMonkeyValue command in Selenium-IDE by interactively creating a VerifyProperty command with the FlexMonkiumConsole, and then modifying as described below.
To retrieve a property value, you can create a VerifyProperty for the property, and then just change the command name from waitForFlexMonkey to getFlexMonkeyValue. In the "value" field of the command in Se-IDE, put the name of the variable where you want the value stored. For example, you could run the following commands from Se-IDE:
| Command | Locator | Value | |
| getFlexMonkeyValue | <VerifyProperty.../> | someVar | Retrieves the property value identified by the VerifyProperty command, and stores the result in the Selenium variable someVar. |
| echo | ${someVar} | Print value to Se-IDE console. |
Within Se-IDE, you can use ${vars} within FlexMonkey XML commands, so you can, for example, retrieve the value from one field, and then use it later as input to another.
To retrieve a grid cell value, change the XML command from VerifyProperty to VerifyGrid, and specify the grid itself as the component to be verified. Then add "row" and "col" attributes to the VerifyGrid command specifying the coordinates of the cell whose value you want to retrieve. For example:
getFlexMonkeyValue <VerifyGrid value="SomeGrid" row="0" col="2"/>
When you generate code, for the "get" commands you'll get something like this:
proc.getString("getFlexMonkeyValue", new String[] {"<VerifyGrid row=\"0\" col=\"2\" value=\"grid\" prop=\"automationName\">"});
You will need of course to add a variable to the generated code to actually store the result, eg:
String result = proc.getString....
Currently, FlexMoney commands are stored as XML within the locator field of the following Selenium commands
flexMonkey – Execute the FlexMonkey command
xxxFlexMonkey – Evaluate the FlexMonkey verify command as the corresponding Selenium xxx command, where xxx is one of verify, assert, waitFor.
getFlexMonkeyValue - Retrieve the value specified for verification by the FlexMonkey verify command.
FlexMonkium generates JUnit-based tests for use with Selenium-RC. To generate a test, select Export Test Case/Suite as… > FlexMonkium (JUnit) – Selenium-RC from the Selenium-IDE File menu. To learn more about running JUnit tests with Selenium-RC, see the Selenium-RC User guide.
Note: You must export as FlexMonkium (JUNit) - Selenium-RC. The other Selenium export formats (Ruby, etc.), are not currently supported by FlexMonkium.
When starting the Selenium-RC server, you must include the FlexMonkium extensions by supplying a path to FlexMonkium’s user-extension.js file. For example:
java -jar selenium-server.jar -userExtensions /pathToFlexMonkium/user-extensions.js To Run Selinium Junit tests from command line you need the following on your classpath
To Set your class path used the following
Windows Example:
set CLASSPATH=%JUNIT_HOME%\junit.jar;c:\myproject\lib\selinium-java-client.jar
Unix (bash) Example:
export CLASSPATH=$JUNIT_HOME/junit.jar:/myproject/lib/selinium-java-client.jar
compile your class file using javac [fileyounamedinselinium].java To run the tests run this command (java org.junit.runner.JUnitCore <test class name>)