Thursday, August 5, 2010

Setting up flex testing with selenium

Recently I was looking for tools to support automated testing for flex applications. I have a test suite in SeleniumRC and C# I was looking for options to continue using this environment. Here’s what I found:

FlashSelenium, Selenium Flex API

These two projects provides capabilities to interact with Flex UI components and web pages through selenium RC.

Selenium Flex API automatically exposes Flex APP UI and FlashSelenium  allowing us to call ActionScript methods to interact with Flex elements. Note that this approach requires us to compile our flex applications with Selenium Flex API library.

To start coding your test:

  • Rebuild your Flex application with sfapi.swc add the compiler argument:  -include-libraries "..\libs\sfapi.swc"
  • Include FlashSelenium.dll library in the seleniumRC test project.

To be able to run test on firefox you need to specify the browserString *firefoxproxy instead of *firefox since firefox doesn't like javascript calling flash when javascript comes from another window (the way selenium calls flash objects).

This a “hello world” example:

public class MyAppInFlexTest
private ISelenium selenium;
private FlashSelenium.FlashSelenium flashApp;

public void SetupTest()
selenium = new DefaultSelenium("localhost", 4444, @"*firefoxproxy", @"http://localhost/testapp.html");
//selenium = new DefaultSelenium("localhost", 4444, @"*iexplore", @"http://localhost/testapp.html");
//selenium = new DefaultSelenium("localhost", 4444, @"*googlechorme", @http://localhost/testapp.html);
flashApp = new FlashSelenium.FlashSelenium(selenium, "MyAppInFlex");

public void TeardownTest()

public void TestMethodFlashSelenium()
flashApp.Call("doFlexType", "usernameTextInput", "from selenium flex");
flashApp.Call("doFlexClick", "secureCheckBox", "");


  1. Hi Maria,
    I like your post, there are a lot of posts that speak on basics of selenium . This one is interesting as it speaks about Selenium wrt Flex apps.
    This surely makes it a candidate on my blog which has the best articles and posts across the web.I'm sure you would be happy to see your post there do let me know if you want any changes.

    My blog:

  2. Thanks @Aditya Kalra. Take a look at my post about selenium testing with FlexPilot.

  3. Hi Maria,
    Thanks for interesting article.
    I have a question for you:
    could you please rewrite JAVA part in Python since I used to write in Python and can't get this JAVA well.