yandex

automation of flex applications

Monday, 02 June 2014 09:22

This article deals with the following automation tools for Flex applications:

  • Flex Pilot
  • Selenium Flex API
  • Selenium WebDriver + Selenium IDE/FlexMonkium

We’ll also discuss the use of one of them on example of the Flex application shown at the picture below.

Application Example

Meanwhile, let’s pick the best tool of the above to automate the testing of our application

Flex Pilot

It’s Open Source project that allows you to control flex application in tandem with Selenium.

Cons:

  • partially interacts only with standard components
  • most of the custom components can not be automated (or the costs of automation are too high)
  • poor functionality
  • almost complete lack of documentation

Pros:

  • it is possible to record users’ actions, using a plugin for Selenium IDE (but a correct running of this feature did not succeed)
  • the project is currently still being developed (maybe it’ll die later)
  • the ability to search for components not only by name and id, but also by attributes, childs and chain
  • The essence of integration with the flex application is loading with the application an swf file flex-pilot, which provides external-functions for interacting with the flex application.
  • Selenium Flex API
  • Flex API
  • One more Open Source project that allows you to control flex application in tandem with Selenium.

Cons:

  • interacts only with standard components (except for the latest versions of Flex);
  • support for custom components is open to question
  • components can be found only by name and id
  • there is no possibility of recording user actions
  • almost complete lack of documentation
  • project is no longer supported

Pros:

  • good support for standard components (except for the latest versions of Flex);
  • sufficiently advanced functionality
  • The essence of integration with the flex application is compiling the project with sfapi.swc (provides external-functions to interact with the flex application)
  • Selenium WebDriver + Selenium IDE/FlexMonkium

Flexmonkium

FlexMonkey tool for testing Adobe Flex and AIR applications.

FlexMonkium plugin for Selenium IDE, which allows you to record and play back FlexMonkey tests using Selenium.

Cons:

  • as such there are no minuses, but it’s open source project with all the consequences
  • it is necessary to develop your own delegates for support of custom components

Pros:

  • good support of developers
  • good documentation
  • full support for standard components
  • different ways to find items
  • ability to record and playback tests
  • there are debugging tools tests
  • good integration with Selenium, which allows to combine the testing of mixed applications
  • The essence of integration with the flex application is compiling the project withflexmonkey.swc (opens access to their management functions of flex application for Selenium)

What tool to choose?

For obvious reasons (see the pros and cons), the best solution for testing Flex applications will be use of Selenium WebDriver + Selenium IDE / FlexMonkium.

Note: During the test automation of the application offered by me, only the Selenium Flex API and Selenium WebDriver + Selenium IDE / FlexMonkium coped with the task. Flex Pilot failed to automate the testing of the application fully. Testing Flex applications with Selenium WebDriver + Selenium IDE / FlexMonkium

So, follow these steps:

  • Download FlexMonkium.
  • In the archive FlexMonkium.zip choose one swc, which is suitable for your version of Flex
  • Then drag it to a folder with your project
  • Add the compiler arguments: “-include-libraries automation_monkeyx.x.swc”
  • After that, compile the project
  • Now your project is ready to interact with FlexMonkium
  • Also from the archive, you must install plugin for Selenium IDE
  • If you do not have Selenium IDE, then you need to install it

After everything is set up, you can begin to write the first test. If everything goes correctly, by making a couple of clicks in the Selenium IDE, actions performed by you will be added (see figure below).

Selenium IDE

To call these commands from Selenium WebDriver use JavascriptExecutor.

How the call of FlexMonkey function from Selenium WebDriver will look, we can see at the example function click():

public void click(String locator) { JavascriptExecutor js = (JavascriptExecutor) driver; try { Thread.sleep(delay); this.js.executeScript("return window.document['app'].playFromSelenium('', '')"); } catch (WebDriverException e) { System.out.print(e); } catch (InterruptedException e) { System.out.print(e); } }

And as we can see, to interact with Selenium, exteranal-function PlayFromSelenium (command, text) is used, where the command is a command which can be seen in the Target field in the Selenium IDE. To use this method, refer to the Flash object for which we use the following line:



window.document['app']
where‘ app’ is the name of flash object:
    embed align = "middle"
    width = "500"
    height = "500"
    pluginspage = "/go/getflashplayer"
    type = "application/x-shockwave-flash"
    allowscriptaccess = "*"
    name = "app"
    bgcolor = "#ffffff"
    quality = "high"
    src = "/application.swf"

As we can see, automation of Flex applications is easy!

IntexSoft is in the Clutch Top 10 of Belarusian Web & Software Developers More