Saturday, August 28, 2010

Testing Flash With Selenium

Is it possible to test Flash with Selenium? Yes, but it is difficult. Before seeing how much difficult it is, let us see how to test Flash in Selenium.

Testing the Flash is possible using External Interface Command in ActionScript. External Interface allows the JavaScript to interact with the ActionScript. Here is the list of actions we can do,

From ActionScript, you can do the following on the HTML page:
  • Call any JavaScript function.
  • Pass any number of arguments, with any names.
  • Pass various data types (Boolean, Number, String, and so on).
  • Receive a return value from the JavaScript function.
From JavaScript on the HTML page, you can:
  • Call an ActionScript function.
  • Pass arguments using standard function call notation.
  • Return a value to the JavaScript function.
Flash Player does not currently support SWF files embedded within HTML forms.

So, if you call a ActionsScript function via JavaScript, that action will be performed in the Flash. This is the method used by the Flash-Selenium and similar projects to test Flash using Selenium. 

To test a Flash app using this method, all Flash functions should be exposed via ExternalInterface to JavaScript. If it is not, that function can't be called via JavaScript. If the Flash app has a lot of functions needed to be tested, exposing all of them using ExternalInterface is cumbersome or sometimes may not be possible. 

So, if your app has less functions that needs to be tested, you can use this approach, if not, testing manually will be the better option.

Also check this article for more info,

Thanks to Vinod for helping in this. 


raja's shared items

My "Testing" Bundle