Click here to Skip to main content
Licence CPOL
First Posted 4 Oct 2010
Views 5,008
Bookmarked 0 times

Setting up flex testing with selenium

By | 4 Oct 2010 | Technical Blog
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 wit
A Technical Blog article. View original blog here.[^]

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:

[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", "");
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

mariangemarcano



Mexico Mexico

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 4 Oct 2010
Article Copyright 2010 by mariangemarcano
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid