Malinga Thennakoon Damith Liyanaarachchi
 Finding suitable framework to capture flash objects in web browser automation testing.  Configuring them with the existing framework.  Analyzing major drawbacks of the existing tools and finding better tools for flash object capturing.
 Flash objects communicate with the browser with its platform dependant native methods.  Flash objects are implemented using Adobe Action Script as Flash applications or MXML and Action Script as Flex Applications.  Flash UI Components do not have XPATHs.  Flash Objects communicate with both client side and server side simultaneously , therefore difficult to identify parsing parameters.
 For the Millennium BBO application ,it’s Flash components dynamically communicate with the server to retrieve information using external JavaScript files.  HierarchyViewer.swf uses adfHierarchyViewer.js to retrieve data from the MIT server.  HierarchyViewer.swf is created dynamically at the run time by the ADF faces technology and also created using JDeveloper tool at the development time.  No API is published.
 Flash objects on a webpage are accessible by some JavaScript functions. Such as ◦ GetVariable(varName) ◦ SetVariable(varName, varValue) ◦ TCallLabel(target, label)  Flash API consists of a class called External Interface in order to interact with the JavaScript functions.
 Two main functions are used  Call method()  AddCallBack method() public function ColoredSquare() { currentColor = COLOR_HEX_VALUES[currentColorIndex % 3]; updateButtonLabel(); drawButton(); addEventListener(MouseEvent.CLICK, buttonClicked); // functions available for JavaSript calls ExternalInterface.addCallback("getColor", getColor); ExternalInterface.addCallback("click", changeColor); ExternalInterface.addCallback("getSquareLabel", getSquareLabel); ExternalInterface.addCallback("setSquareLabel", setSquareLabel); }
 ExternalInterface.Call method  This is used to call JavaScript functions from the ActionScript code.  Eg:- ExternalInterface.Call (“callToJS”);  ExternalInterface.AddCallBack method  This is used to call relevant ActionScript method as a response to JavaScrirpt method calling  Eg:- ExternalInterface.AddCallBack (“callFromJS”,”Actual ActionScript Function”);
 In order to test flash objects in web applications a middle ware is needed to provide this inter communication.  To send testing parameters to Flash objects and retrieve the results.  Finding out such tools and configure them with the existing framework is essential to flash testing
 Flash Selenium API  Flex UI Selenium API  FlexSelenium.swc  Adobe Flex SDK  Adobe Flex Builder  Sothinnk Flash De-compiler  Genie Framework (newest addition )
 White box testing. we need to know about the internal coding of the Flash application in order to perform the test.  Compatible with the Selenium RC and Web Driver.  Selenium IDE cannot be used.  Flash UI components are identified by specific id called Flash Object ID which is equivalent to the XPATH of the HTML elements.
Steps Obtain Flash object as .swf file or .mxml file. If the file is in .swf format decompile using a De- compiler. Obtain the Action Script code or the mxml code and analyze it using Adobe Flex Builder. Add External interface class to the project and define functions which wraps the internal functions which should be tested.  These functions should map the external Java Script calling methods with the Action Script internal methods.
public function ColoredSquare() { currentColor = COLOR_HEX_VALUES[currentColorIndex % 3]; updateButtonLabel(); drawButton(); addEventListener(MouseEvent.CLICK, buttonClicked); // functions available for JavaSript calls ExternalInterface.addCallback("getColor", getColor); ExternalInterface.addCallback("click", changeColor); ExternalInterface.addCallback("getSquareLabel", getSquareLabel); ExternalInterface.addCallback("setSquareLabel", setSquareLabel); } Java Script Calling Action Script Calling
 Recompile the file to obtain the swf file test the Flash object using Selenium RC as follows. public void testColorTransition() { assertEquals("Clicking Colors", browser.getTitle()); assertEquals(GREEN, flashseleneium.call("getColor")); flashseleneium.call("click"); assertEquals(BLUE, flashseleneium.call("getColor")); flashseleneium.call("click"); assertEquals(RED, flashseleneium.call("getColor")); flashseleneium.call("click"); assertEquals(GREEN, flashseleneium.call("getColor")); }
 Flex UI selenium can be used to test Flash UI components instead of its functions.  Every UI component is identified by its Flash object ID.  Flex UI selenium library should be added to the build path of the Flash/Flex File in order to communicate with the Flex UI and Flash Selenium Libraries.
Obtain Flash object as .swf file or .mxml file. If the file is in .swf format decompile using a De- compiler. Obtain the Action Script code or the mxml code and analyze it using Adobe Flex Builder. Extract and analyze the Flash object ids of UI components of the application. Add FlexSelenium.swc to the build path and recompile the file using Adobe Flex SDK. Write test cases against the UI components and their Functionalities using selenium RC.
 public void testFlashCal(){  try {  Thread.sleep(4000);  //---------- Following part is for test using the Flex UI Selenium part  flexUi.type("50").at("num");  flexUi.type("2").at("factor");  //flexUi.type("2").at("factor");  Thread.sleep(500);  assertEquals("The result is 100",flexUi.readFrom("result"));  for (int i = 1; i <=10 ; i++) {  flexUi.click("button");  Thread.sleep(500);  if(i ==1){  assertEquals("pushed "+i+" time" ,flexUi.readFrom("buttonClicks"));  }  else{  assertEquals("pushed "+i+" times" ,flexUi.readFrom("buttonClicks"));  }  Thread.sleep(500);  }  flexUi.click("comboQuote");  assertEquals("" ,flexUi.readFrom("buttonClicks"));
 No single IDE to configure all of above configurations. Because of the multiple software components and multiple versions.  Time consuming  Flex –UI selenium is still in its development stage and not compatible with eclipse higher versions.  Internal Action Script / Flex codes should be understood by the tester.  For the MIT BBO application, they are using ADF faces technology where the flash application independently connected with the server to obtain data.
 Newest addition to the Flash UI testing.  Equivalent to the Selenium Framework.  Compatible with Eclipse Higher versions (3.5.0 etc).  Support UI component testing using inbuilt IDE.  UI components are captured by the accessing internal ActionScript code of the Flash object.  Every component is uniquely identified by an Id called Genie ID.
 Completely written in Java. Therefore can be integrated with the existing Testing Framework.  Provide in-built functions to capture Flash UI components.  Available as a plug-in for Eclipse.  Test scripts can be generated using Java.  Complete API is available.
 No instrumentation or application manipulation is required.  Automate pure ActionScript 3.0 SWF.  No source code access required.  No need to run inside any wrapper.  Works on web based apps and standalone SWF.  Performs native automation (no image dependency) thus making scripts reliable and lowering down maintenance cost.  Application can even be running in background.
 Dynamic and static content can be tested.  Each and every Flash component is uniquely identified using the Genie id.
 http://code.google.com/p/sfapi/  http://code.google.com/p/flex-ui-selenium/  http://wiki.openqa.org/display/SRC/Testing+Flash+with+Sel enium+RC  http://www.senocular.com/flash/tutorials/as3withmxmlc/  http://sourceforge.net/adobe/genie/wiki/Home/

Flash Testing with Selenium RC

  • 1.
  • 2.
     Finding suitableframework to capture flash objects in web browser automation testing.  Configuring them with the existing framework.  Analyzing major drawbacks of the existing tools and finding better tools for flash object capturing.
  • 3.
     Flash objectscommunicate with the browser with its platform dependant native methods.  Flash objects are implemented using Adobe Action Script as Flash applications or MXML and Action Script as Flex Applications.  Flash UI Components do not have XPATHs.  Flash Objects communicate with both client side and server side simultaneously , therefore difficult to identify parsing parameters.
  • 4.
     For theMillennium BBO application ,it’s Flash components dynamically communicate with the server to retrieve information using external JavaScript files.  HierarchyViewer.swf uses adfHierarchyViewer.js to retrieve data from the MIT server.  HierarchyViewer.swf is created dynamically at the run time by the ADF faces technology and also created using JDeveloper tool at the development time.  No API is published.
  • 5.
     Flash objectson a webpage are accessible by some JavaScript functions. Such as ◦ GetVariable(varName) ◦ SetVariable(varName, varValue) ◦ TCallLabel(target, label)  Flash API consists of a class called External Interface in order to interact with the JavaScript functions.
  • 7.
     Two mainfunctions are used  Call method()  AddCallBack method() public function ColoredSquare() { currentColor = COLOR_HEX_VALUES[currentColorIndex % 3]; updateButtonLabel(); drawButton(); addEventListener(MouseEvent.CLICK, buttonClicked); // functions available for JavaSript calls ExternalInterface.addCallback("getColor", getColor); ExternalInterface.addCallback("click", changeColor); ExternalInterface.addCallback("getSquareLabel", getSquareLabel); ExternalInterface.addCallback("setSquareLabel", setSquareLabel); }
  • 8.
     ExternalInterface.Call method This is used to call JavaScript functions from the ActionScript code.  Eg:- ExternalInterface.Call (“callToJS”);  ExternalInterface.AddCallBack method  This is used to call relevant ActionScript method as a response to JavaScrirpt method calling  Eg:- ExternalInterface.AddCallBack (“callFromJS”,”Actual ActionScript Function”);
  • 9.
     In orderto test flash objects in web applications a middle ware is needed to provide this inter communication.  To send testing parameters to Flash objects and retrieve the results.  Finding out such tools and configure them with the existing framework is essential to flash testing
  • 10.
     Flash SeleniumAPI  Flex UI Selenium API  FlexSelenium.swc  Adobe Flex SDK  Adobe Flex Builder  Sothinnk Flash De-compiler  Genie Framework (newest addition )
  • 11.
     White boxtesting. we need to know about the internal coding of the Flash application in order to perform the test.  Compatible with the Selenium RC and Web Driver.  Selenium IDE cannot be used.  Flash UI components are identified by specific id called Flash Object ID which is equivalent to the XPATH of the HTML elements.
  • 13.
    Steps Obtain Flash objectas .swf file or .mxml file. If the file is in .swf format decompile using a De- compiler. Obtain the Action Script code or the mxml code and analyze it using Adobe Flex Builder. Add External interface class to the project and define functions which wraps the internal functions which should be tested.  These functions should map the external Java Script calling methods with the Action Script internal methods.
  • 14.
    public function ColoredSquare(){ currentColor = COLOR_HEX_VALUES[currentColorIndex % 3]; updateButtonLabel(); drawButton(); addEventListener(MouseEvent.CLICK, buttonClicked); // functions available for JavaSript calls ExternalInterface.addCallback("getColor", getColor); ExternalInterface.addCallback("click", changeColor); ExternalInterface.addCallback("getSquareLabel", getSquareLabel); ExternalInterface.addCallback("setSquareLabel", setSquareLabel); } Java Script Calling Action Script Calling
  • 15.
     Recompile thefile to obtain the swf file test the Flash object using Selenium RC as follows. public void testColorTransition() { assertEquals("Clicking Colors", browser.getTitle()); assertEquals(GREEN, flashseleneium.call("getColor")); flashseleneium.call("click"); assertEquals(BLUE, flashseleneium.call("getColor")); flashseleneium.call("click"); assertEquals(RED, flashseleneium.call("getColor")); flashseleneium.call("click"); assertEquals(GREEN, flashseleneium.call("getColor")); }
  • 16.
     Flex UIselenium can be used to test Flash UI components instead of its functions.  Every UI component is identified by its Flash object ID.  Flex UI selenium library should be added to the build path of the Flash/Flex File in order to communicate with the Flex UI and Flash Selenium Libraries.
  • 17.
    Obtain Flash objectas .swf file or .mxml file. If the file is in .swf format decompile using a De- compiler. Obtain the Action Script code or the mxml code and analyze it using Adobe Flex Builder. Extract and analyze the Flash object ids of UI components of the application. Add FlexSelenium.swc to the build path and recompile the file using Adobe Flex SDK. Write test cases against the UI components and their Functionalities using selenium RC.
  • 18.
     public voidtestFlashCal(){  try {  Thread.sleep(4000);  //---------- Following part is for test using the Flex UI Selenium part  flexUi.type("50").at("num");  flexUi.type("2").at("factor");  //flexUi.type("2").at("factor");  Thread.sleep(500);  assertEquals("The result is 100",flexUi.readFrom("result"));  for (int i = 1; i <=10 ; i++) {  flexUi.click("button");  Thread.sleep(500);  if(i ==1){  assertEquals("pushed "+i+" time" ,flexUi.readFrom("buttonClicks"));  }  else{  assertEquals("pushed "+i+" times" ,flexUi.readFrom("buttonClicks"));  }  Thread.sleep(500);  }  flexUi.click("comboQuote");  assertEquals("" ,flexUi.readFrom("buttonClicks"));
  • 19.
     No singleIDE to configure all of above configurations. Because of the multiple software components and multiple versions.  Time consuming  Flex –UI selenium is still in its development stage and not compatible with eclipse higher versions.  Internal Action Script / Flex codes should be understood by the tester.  For the MIT BBO application, they are using ADF faces technology where the flash application independently connected with the server to obtain data.
  • 20.
     Newest additionto the Flash UI testing.  Equivalent to the Selenium Framework.  Compatible with Eclipse Higher versions (3.5.0 etc).  Support UI component testing using inbuilt IDE.  UI components are captured by the accessing internal ActionScript code of the Flash object.  Every component is uniquely identified by an Id called Genie ID.
  • 21.
     Completely writtenin Java. Therefore can be integrated with the existing Testing Framework.  Provide in-built functions to capture Flash UI components.  Available as a plug-in for Eclipse.  Test scripts can be generated using Java.  Complete API is available.
  • 22.
     No instrumentationor application manipulation is required.  Automate pure ActionScript 3.0 SWF.  No source code access required.  No need to run inside any wrapper.  Works on web based apps and standalone SWF.  Performs native automation (no image dependency) thus making scripts reliable and lowering down maintenance cost.  Application can even be running in background.
  • 23.
     Dynamic andstatic content can be tested.  Each and every Flash component is uniquely identified using the Genie id.
  • 24.
     http://code.google.com/p/sfapi/  http://code.google.com/p/flex-ui-selenium/ http://wiki.openqa.org/display/SRC/Testing+Flash+with+Sel enium+RC  http://www.senocular.com/flash/tutorials/as3withmxmlc/  http://sourceforge.net/adobe/genie/wiki/Home/