How to perform Flash Testing with Selenium WebDriver?

Today we are going to discuss an interesting topic; you may go back to your childhood flashback. If you remember, during 2000 to the 2008-09 era when we initially had hands-on experience with our first computer then we used to play some light games like Road Rash, some boating puzzle game, Online worship games, Salman’s Sleep Walk game, Hit the Egg games, etc. If you put some more stress to your memory, then you could remember that Macromedia logo with powerful party background music when the player was getting started. These applications were built with Flash, so today we are going to discuss flash testing with Selenium WebDriver.

Road Rash Games Flash Testing

Flash Game of 90s

Nowadays, web developers negligibly use Flash based web application, but to some extent, this application is used. Hence, we can find them at video sharing sites and few of them at entertainment websites. Today SEO (Search Engine Optimization) became the core component for online business so Search engine crawlers can’t crawl and detect the contents developed with Flash easily, hence, it is replaced by HTML 5. So, most of the web development projects are built around HTML 5 and CSS 3.

Don’t Miss: Technique to handle SSL untrusted Certificate using Selenium

What is Flash?

Adobe Flash (Earlier Macromedia Flash) is a multimedia vector graphic platform which is used to create animation videos, web applications, websites, desktop applications, mobile games for Android and iOS, mobile applications and embedded videos for websites.

Some of the editor software for flash applications are listed below:

  • Power Flasher
  • Adobe Animate
  • Flash Catalyst
  • Flash Develop
  • Scaleform
  • Flash Builder

We need plugins to play the Flash applications and the plugins are listed as follows:

  • Flash Player
  • Adobe Air
  • ScaleForm
  • Lightspark
  • OpenFL
  • Gnash

Pre-requisites for Flash testing with Selenium WebDriver

We should be ready with the pre-requisites for Flash testing with Selenium WebDriver. Here is the list of pre-requisites:

  • Flash Web Application
  • Flash Player plugins
  • Native browser support

How to perform Flash testing using Selenium WebDriver?

We need to download the Flash Selenium jar file to import the Flash library. Click here to go to the Flash Selenium archive page. Click here to download Flash.jar file for Selenium WebDriver. Further, you need to add the jar file to your project.

Once all the pre-requisites are satisfied then call FlashObjectWebDriver, here is the example:

FlashObjectWebDriver fow = new FlashObjectWebDriver(webDriver, “object of flash”);

This class allows us to perform the action on Flash players. Following sample program performs the action on a video player.

package Test;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import Flash.FlashObjectWebDriver;

public class FlashDemo {

	public static void main(String[] args) throws InterruptedException {
		System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");
	  	 
		WebDriver driver  = new ChromeDriver();
		
		driver.get("your url");
		
		driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
		
		driver.manage().window().maximize();

		FlashObjectWebDriver fow = new FlashObjectWebDriver(driver, "movie_player");
		
		Thread.sleep(6000);
		fow.callFlashObject("pauseVideo");
		
		Thread.sleep(4000);
		fow.callFlashObject("playVideo");
		
		Thread.sleep(4000);
		fow.callFlashObject("seekTo","90","true");
		
		Thread.sleep(4000);
		fow.callFlashObject("setVolume","70");
		
		Thread.sleep(4000);
		fow.callFlashObject("mute");
		
		Thread.sleep(4000);
	    
		driver.close();
		driver.quit();
	}

}

ExternalInterface and ActionScript for Flash testing

Every programming language has bundles to interact exclusively with the buttons like AWT library in Java. Selenium does not have any direct interface to perform actions with Flash objects. Like JavaScript, Flash files use programming interface called as ActionScript. To perform any action like click, play, pause, etc we need to call the methods of flash files.

Now our task is to expose those internal methods to the real world so that we could use them extensively for testing purposes. Here comes ExternalInterface class. It makes internal bindings available to use for testing by injection of JavaScript in it.

Click here to see the uses and implementation of ExternalInterface for flash testing with Selenium.

ExternalInterface for Flash testing in Selenium

That’s all about Flash Testing with Selenium WebDriver. Please share your thoughts on this article. If you haven’t joined our Facebook group yet, then click on the below image to join it.

Join Inviul fb group

4 Comments

Leave a Reply