FlexMonkey 5.1.1: how to actually compile flexmonkey

26 01 2012

So, I recently started learning how to use FlexMonkey in order to bring some sort of UI Automation to the project I am working on for work, but debugging problems in it can be a hassle when you only have a magical “swc” file, which means you can’t view the source code when you are debugging. Highly annoying! So this post talks about how to actually compile flexmonkey into your application.

For this, you will need a couple of things. Flash builder for one, I am using 4.6,  and subversion to actually download the flex monkey source code

First off, for whatever reason, they require you to have a gorillamonkey.com account in order to download the source code, so go here: http://www.gorillalogic.com/user/register and register for an account.

Then, fire up a terminal and cd to whatever directory you want to put the code into (temporarily) , and type

svn export https://svn.gorillalogic.com/svn/flexmonkey/trunk

This will check out the latest revision and NOT leave the stupid .svn folders laying around everywhere. So open up the trunk folder, and inside you should see the MonkeyLink folder. Inside this folder, there are 3 folders, libs, js and src. You should merge the contents of this folder with your own project code, so now you have some stuff in /src, /js and /libs .

Second part, you need to right click on your project in the navigation tree on the left, go to properties -> flex compiler, and copy/paste this line after anything else that is there:

-include-libraries "${flexlib}/libs/automation/automation_spark.swc" "${flexlib}/libs/automation/automation.swc" "${flexlib}/libs/automation/automation_agent.swc" "${flexlib}/libs/automation/automation_dmv.swc"

Then, you need some libraries that Flexmonkey compiles against. These are the ones that worked for me, you might need specific versions if you are using flex 3 or flex 4 (mostly the Flexunit libraries differs between flex 3/4). You should be able to drop these in the ‘libs’ folder of your flex project and Flash Builder will automatically link them.

  • as3commons-bytecode-0.8.5.swc
  • as3commons-lang-0.3.1.swc
  • as3commons-reflect-1.3.1.swc
  • as3commons-logging-1.1.1.swc
  • flexunit-4.1.0_RC2-4-flex_4.1.0.16076.swc
  • flexunit_aircilistener-4.1.0_RC2-4.4.1.0.16076.swc
  • flexunit-cilistener-4.1.0_RC2-4-4.1.0.16076.swc
  • hamcrest-as3-1.1.0.swc

Now, to avoid Gotcha #1,  you need to actually REFERENCE the code before it will compile it. This one is annoying because you don’t actually have to reference anything in the monkeylink/flexmonkey code to make it work, since it initializes it self using the [mixin] metadata tag, but flex in it’s infinite wisdom chooses not to compile things unless they are referenced. So go to your <fx:script> tag in your main mxml file or somewhere, and just auto complete a variable (start by typing var something:Monkey… and then hit ctrl + space so flex will automatically import it for you) and then recompile. Note, you need to actually create a monkeylink object, just having the import and a undefined variable (var link:monkeylink;) is not enough, you need to do ‘new MonkeyLink()”. We should be good now right?

Wrong! I have _no_ clue what they are doing, but they what appears to be preprocessing instructions in their actionscript code, except for the fact that as3 doesn’t support them, so it gets interpreted as valid AS3 and you get wonderful errors like “Types are ambiguous, both mx.core.application and spark.components.application exist” and duplicate function definitions. So, in order to fix this, we need to get rid of all these preprocessor statements and as3 code that is meant for Flex 3 (since I am using flex 4). These are the rough locations (as of revision 652) of what i had to remove:

  • removed duplicate functions ( keep code in the else block of the if else, and then delete the if..else ) in MonkeyMagicAutomator.as line 200
  • kept code in if block in ApplicationWrapper.as, deleted if..else line 19
  • kept code in if block in MonkeyAutomationManager.as, deleted if..else line 33
  • got rid of if flex4 block in MonkeyMagicAutomator.as line 18 (kept code inside)
  • kept code in if block, deleted if..else in MonkeyLink.as line 131
  • got rid of if block (kept code inside) in MonkeyLink.as line 40
  • got rid of flex4 block (but kept code inside) in MagicMonkeyAutomationDelegate.as like 413
  • kept code in if block , got rid of if.else in MonkeyAutomationManager.as line 54

Now, if you got all of them, the code SHOULD compile. and that is it! when you start up your application, SystemManager will call the flexmonkey code (because of the [mixin] metadata tag) to do the necessary startup that it does, and you should be able to connect to it via the FlexMonkey air app. I hope this helped!

About these ads

Actions

Information

4 responses

30 03 2012
Tom Lee

Hey there, just thought I’d clue you in on those odd pieces of code you had to remove. They’re basically conditional compilation instructions, and you can learn more about them here:

http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_21.html

If you wanted to, you could define these in your compiler options instead of removing the blocks.

Cheers!

31 03 2012
polygon89

whoa, thanks! i knew about compiler instructions, i just didn’t know that actionscript/flex supported them! i’ll update this article and fix it, since its a lot easier to add a compiler option then deleting code.

15 06 2012
julian

I went a similar way to compile flexmonkey, except I’m using maven to build it, which required some pom.xml building..

However, i had a Problem with the StoreValue + Verify Commands: The verify didn’t work when running the generated flexunit code (didn’t found the stored value – it actually wasn’t stored).

Could you please tell me if you’re encountering the same issue?
I fixed it for me and already posted in the flexmonkey forum.
Since it is down today I can’t post a link, sorry.

4 02 2014
Flex Monkey with Flex SDK 4.11 | Peukalo

[…] It seems that Flex Monkey is not working with the new Flex SDK 4.10+ releases. Recording gives error with almost every component. Not a big surprise as there’s been no new official Flex Monkey releases in years. Luckily the source code is available and Mark Grandi is nicely explaining the process of obtaining and setting up the Flex Monkey -project in his blog post. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.

%d bloggers like this: