Flash Testing with Selenium RC

DamithLiyanaarachchi 349 views 24 slides Oct 21, 2015
Slide 1
Slide 1 of 24
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24

About This Presentation

No description available for this slideshow.


Slide Content

Flash Testing with Selenium RC 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. Research Objectives

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. Why Flash Object capturing is difficult ?

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. Some Examples …

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. Action Script JavaScript Communication

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 ); } Action Script JavaScript Communication

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”); Action Script JavaScript Communication

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 Therefore..

Flash Selenium API Flex UI Selenium API FlexSelenium.swc Adobe Flex SDK Adobe Flex Builder Sothinnk Flash De-compiler Genie Framework (newest addition ) Existing tools

Flash testing using Flash Selenium 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.

Flash testing using Flash Selenium

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. Flash testing using Flash Selenium

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 ); } Examples.. 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 ")); } Flash testing using Flash Selenium

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. Flash testing using Flex UI Selenium

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. Steps..

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 ")); Examples..

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. Drawbacks..

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. Genie FrameWork

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. Genie FrameWork

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. Features of Genie Framework

Dynamic and static content can be tested. Each and every Flash component is uniquely identified using the Genie id. Features of Genie Framework

http://code.google.com/p/sfapi/ http://code.google.com/p/flex-ui-selenium/ http://wiki.openqa.org/display/SRC/Testing+Flash+with+Selenium+RC http://www.senocular.com/flash/tutorials/as3withmxmlc/ http://sourceforge.net/adobe/genie/wiki/Home/ References
Tags