[Selenium+Java] Flash Testing with Selenium

家住魔仙堡 提交于 2020-04-27 21:42:34

Original URL: https://www.guru99.com/flash-testing-selenium.html

Flash Testing with Selenium

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 operation on that particular element. But in Flash testing, XPath fails to access flash object. So Flashwebdriver object is required to find flash object in any application.

Flash Testing with Selenium

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

In this tutorial, you will learn-

What is Flash Testing?

Flash Testing is testing type used to check the 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 very popular software developed by Mircomedia (now acquired by Adobe). It is used to develop games, applications, graphic based animations, movie, Mobile games, programs, etc. In

Pre-requisite-Below are the requirements in order to test the flash application

  1. Flash Application.
  2. Support 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 framework across different platform and in a different language. It's an open source tool and can be downloaded from official website. It is easy to configure, use and implement.

How Flash testing is different from other element

  • Why flash object capturing is 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 Flash object on a mobile device.

Developing flash is more difficult than developing HTML page with 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 the problems like performance and security.

  • What ways flash application is 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 use to write a script using any automation tool like Selenium, SoapUI, TestComplete, etc. and execute the script.
  • Difference between the Flash and other element.

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

How can Youget flash object ID of flash movie / flash app

In any Web pages, 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 ) for interactive content or external application. Object name is used to locate flash object on webpages.

For instance, in below example you can see the flash movie is defined in an "embed" tag in 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 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, developer needs to assign appropriate object ID.

Below screen shows the object ID "MyFlashMovie" is assigned for the Flash:

Flash Testing with Selenium

How to automate Flash using Selenium IDE recording

You can also automate the flash using Selenium IDE.

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

Flash Testing with Selenium

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

Flash Testing with Selenium

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

Flash Testing with Selenium

How to automate Flash using Selenium Webdriver.

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

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

Flash Testing with Selenium

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

Flash Testing with Selenium

After adding 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 result in testing gets abort and hence fails to test Flash object.

Creating selenium script for Flash testing.

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

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

Flash Testing with Selenium

Step 2) Write a script in Selenium eclipse and execute it. Below code when executed will do 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 separate FlashObjectWebDriver class		
	FlashObjectWebDriver flashApp = new FlashObjectWebDriver(driver, "myFlashMovie");		
  	// Pass the URL of video		
	driver.get("http://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 flash app is a challenge. To automate flash app, You can use FlexMonkium which is an add-on for Selenium IDE.
  • You might face issue to enable record / playback Flex apps using Selenium-Flexmonkium integration. Solution is that user needs to install and integrate Flex monkium to selenium IDE carefully. Proper installation will enable record to automate flash apps.

Summary:

  • In Flash testing, You need to check the flash video, games, movies, etc. are working as expectation or not.
  • You 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.
  • Main difference between flash and other element is that Flash is embedded in SWF files, while other elements are embedded in HTML files
  • You need to Automate Flash testing normally when the flash object is not easily accessible.
  • Tools useful in flash testing are
  1. Selenium
  2. Soap UI
  3. TestComplete
  4. Test Studio etc.
  • Automating flash app is a challenge. To automate flash app, you can use FlexMonkium which is an add-on for Selenium IDE.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!