Setting up flex testing with selenium - Maria Marcano

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:

Flash Selenium, 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:



[TestClass]
public class MyAppInFlexTest
{
    private ISelenium selenium;
    private FlashSelenium.FlashSelenium flashApp;

    [TestInitialize()]
    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);
        selenium.Start();
        flashApp = new FlashSelenium.FlashSelenium(selenium, "MyAppInFlex");
    }

    [TestCleanup()]
    public void TeardownTest()
    {
            selenium.Stop();
    }

    [TestMethod]
    public void TestMethodFlashSelenium()
    {
        flashApp.Call("doFlexType", "usernameTextInput", "from selenium flex");
        flashApp.Call("doFlexClick", "secureCheckBox", "");
    }
}

Source: Maria Marcano - Setting up flex testing with selenium

Comments

  1. How to include FlashSelenium.dll in to seleniun RC projetc.

    am newbie, please give me the steps

    Regards,
    Kishore.

    ReplyDelete
  2. Hi Kishore,

    FlashSelenium and Selenium Flex API are two projects that support flashflex automation. Selenium Flex API exposes Flex APP UI and FlashSelenium can call ActionScripts to interact with Flex elements.

    Steps :
    1. Rebuild your Flex application with sfapi.swc by adding it to the FlexBuilder in the /src folder(http://code.google.com/p/sfapi/downloads/list)
    2.Then compile with arguments: -include-libraries "..\libs\sfapi.swc"
    3.Download FlashSelenium (http://code.google.com/p/flash-selenium/downloads/detail?name=FlashSelenium.dll&can=2&q=)
    4.Add FlashSelenium to your project:
    Follow this link if you need help on this step: http://www.adobe.com/devnet/flash/articles/flash_selenium.html

    Hope this helped!

    ReplyDelete
  3. Hi i have followed the above steps to automate our application(flash.flex)

    But am getting the below error

    Unable to get Property 'doflexType' undefined...

    Please help.

    ReplyDelete

Post a Comment

Popular posts from this blog

XPATH for IE / internet explorer

All time good software testing books!