Flash Testing with Selenium WebDriver

โšก Smart Summary

Flash Testing with Selenium WebDriver verifies that Flash-based videos, games, and animations function correctly. This resource explains capturing embedded SWF objects, assigning object IDs, and automating playback using Selenium IDE recording and the FlashObjectWebDriver class for reliable validation.

  • ๐Ÿ“Œ Core Purpose: Flash Testing validates that embedded SWF mediaโ€”videos, games, and animationsโ€”behaves exactly as designed.
  • ๐Ÿ”Ž Locator Challenge: XPath cannot reach Flash objects, so a dedicated FlashObjectWebDriver object locates them through the assigned object ID.
  • ๐ŸŽฌ Recording Method: Selenium IDE records actions performed on a Flash movie and replays them with the green Run button.
  • ๐Ÿ’ป WebDriver Method: The FlashObjectWebDriver class calls Play, StopPlay, and SetVariable to control Flash programmatically.
  • โš ๏ธ Key Limitation: Flash is deprecated; FlexMonkium extends Selenium IDE when native record and playback fails.

Flash Testing with Selenium WebDriver

What is Flash Testing?

Flash Testing is a testing type used to check that flash based video, games, movies, etc. are working as expected. In other words, testing the functionality of the flash is known as Flash Testing. Flash is a popular software developed by Macromedia (now acquired by Adobe). It is used to develop games, applications, graphic based animations, movie, Mobile games, programs, etc.

In Selenium Automation, if the elements are not found by the general locators like id, class, name, etc, then XPath is required to find an element on the web page to perform an operation on that particular element. But in Flash testing, XPath fails to access a flash object. So a Flashwebdriver object is required to find a flash object in any application.

Flash Testing

Here you will see how to execute flash Testing and how to do flash testing with Selenium.

Pre-requisite for Flash Testing

Before you start, the following are the requirements in order to test a flash application:

  1. Flash Application.
  2. Supported web browser.
  3. Adobe Flash player plugins.

Tools- Below are the testing tools which are useful in flash testing.

  1. Selenium
  2. Soap UI
  3. TestComplete
  4. Test Studio etc.

Selenium is a very popular tool for web testing. You can create a framework across different platforms and in a different language. It is an open source tool and can be downloaded from the official website. It is easy to configure, use and implement.

How Flash testing is different from other elements

Now that the prerequisites are ready, it helps to understand why Flash behaves differently from standard HTML elements during testing.

  • Why is flash object capturing difficult? How is it resolved?

Flash is an outdated technology. It is difficult to capture a flash object as it is different from HTML. Also, Flash is an embedded SWF file (Small Web Format). It is also difficult to access a Flash object on a mobile device.

Developing flash is more difficult than developing an HTML page from the SEO (Search engine optimization) perspective because flash is not fully readable by the search engine. However, advanced technologies like HTML 5 are introduced to overcome problems like performance and security.

  • In what ways is a flash application tested?

Flash Applications are tested in two ways:

  • Manual โ€“ You can test the Flash object by executing test cases manually as it is simple and easy to test. After bug fixation, you make sure that flash is working properly as expected and provide sign off.
  • Automation โ€“ You write a script using any automation tool like Selenium, SoapUI, TestComplete, etc. and execute the script.
  • Difference between Flash and other elements.

As mentioned above, the main difference between flash and other elements is that Flash is embedded in SWF files, while other elements are embedded in HTML files. That is why HTML is easy to capture compared to flash.

How can You get the flash object ID of a flash movie / flash app

Once you know how Flash differs from HTML, the next step is locating the Flash object itself through its object ID.

In any web page, the < object > tag is used for any embedded multimedia (like Flash, ActiveX, Video etc.). It implies “embed” within an HTML document. This tag defines a container embedded in < object /> or < embed /> tags in an HTML document for interactive content or an external application. The object name is used to locate the flash object on web pages.

For instance, in the below example you can see the flash movie is defined in an “embed” tag in an HTML document or file.

Example:

/* Html page*/
<html>
<body marginwidth="0" marginheight="0">
<embed width="100%" height="100%" name="plugin" src="http://video/movie_play.swf" type="application/flash"/>
</body>
</html>

Using the object ID to find Flash elements.

You can use flash attributes like object id to locate the flash object. And thereby you can perform operations on it as required like play, stop, etc.

As already discussed, Flash objects cannot be accessed using XPath. So in order to do any action on these objects, the developer needs to assign an appropriate object ID.

The below screen shows the object ID “MyFlashMovie” is assigned for the Flash:

Flash Object ID of Flash Movie / Flash App

How to automate Flash using Selenium IDE recording

With the object ID assigned, you can record interactions on the Flash movie directly through Selenium IDE.

You can also automate the flash using Selenium IDE.

Step 1) You need to open the flash application and then Selenium IDE as shown in the below screen:

Automate Flash using Selenium IDE Recording

Step 2) Now click on the “record red button” on the right-hand side and start doing operations on the Flash movie, and then you will find the recorded script as shown below:

Automate Flash using Selenium IDE Recording

After recording, if the user wants to execute the script then they can click on the “green run button” as shown in the below screen. The Selenium IDE will execute the script step by step.

Automate Flash using Selenium IDE Recording

How to automate Flash using Selenium Webdriver

For more control than recording offers, Selenium WebDriver lets you drive the Flash object programmatically.

You can also automate the flash using Selenium web driver through the Flashwebdriver object and then call a method to operate on the flash object. You need to download flashwebdriver jar files:

Step 1) After download, add the jar file in your project as shown in the below screen.

Add Flash jar file in Selenium project

Step 2) Under the flash jar file there is a separate flashobjectwebdriver class. Implement the flashWebdriver “myFlashmovie” in your selenium script as shown below in the screen.

Implement flashWebdriver in Selenium script

After adding the web driver class “MyFlashMovie,” you can access the Flash object.

When to automate flash testing

Usually, you need to automate Flash testing when the flash object is not easily accessible. This results in the test getting aborted and hence failing to test the Flash object.

Creating a selenium script for Flash testing

Bringing the previous steps together, here is a complete working script that launches and controls the Guru99 demo flash movie.

Step 1) You use the “Guru99” flash movie to test the flash scenario.

https://demo.guru99.com/test/flash-testing.html

Guru99 demo flash movie for Selenium testing

Step 2) Write a script in Selenium eclipse and execute it. The below code, when executed, will do the following things:

  • Open the Firefox browser,
  • Launch the guru99 flash site,
  • Play the flash movie and
  • Then stop the movie.
import org.openqa.selenium.firefox.FirefoxDriver;
import Flash.FlashObjectWebDriver;
public class Flash {
    public static void main(String[] args) throws InterruptedException {
        // Open firefox browser
        FirefoxDriver driver = new FirefoxDriver();
        // Maximize browser
        driver.manage().window().maximize();
        // Under Flash jar file there is a separate FlashObjectWebDriver class
        FlashObjectWebDriver flashApp = new FlashObjectWebDriver(driver, "myFlashMovie");
        // Pass the URL of video
        driver.get("https://demo.guru99.com/test/flash-testing.html");
        Thread.sleep(5000);
        flashApp.callFlashObject("Play");
        Thread.sleep(5000);
        flashApp.callFlashObject("StopPlay");
        Thread.sleep(5000);
        flashApp.callFlashObject("SetVariable","/:message","Flash testing using selenium Webdriver");
        System.out.println(flashApp.callFlashObject("GetVariable","/:message"));
    }
}

Step 3) Execute the above script.

Output: On execution of the above script, the flash movie starts to play and stop, etc.

Challenges in Flash Testing

  • Automating a flash app is a challenge. To automate a flash app, you can use FlexMonkium, which is an add-on for Selenium IDE.
  • You might face issues enabling record / playback of Flex apps using the Selenium-Flexmonkium integration. The solution is that the user needs to install and integrate Flexmonkium with Selenium IDE carefully. Proper installation will enable recording to automate flash apps.

FAQs

Adobe officially ended Flash Player support on December 31, 2020. Flash testing now applies mainly to legacy systems, since most applications have migrated to HTML5, which Selenium automates without special Flash libraries.

Flash content renders inside a compiled SWF object embedded in the page, not as HTML DOM elements. Because XPath traverses the DOM, it cannot reach internal Flash controls, so an object ID and FlashObjectWebDriver are required.

FlexMonkium is an add-on that integrates with Selenium IDE to enable record and playback for Flex and Flash applications. Correct installation lets testers capture and replay actions on otherwise inaccessible Flash objects.

AI-based visual testing tools recognize on-screen Flash elements through image and pattern recognition rather than the DOM. This lets teams validate animations and interactions that traditional locators cannot detect.

Yes. AI-assisted tools analyze existing Flash test steps and suggest equivalent HTML5 locators and scripts. This accelerates migration to modern frameworks like Selenium WebDriver while reducing manual rework.

Summarize this post with: