• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Programming Languages
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials
  • Automation Tools and Different Tools
    • Web Automation
      • Selenium with Java
        • Selenium Basic
        • Selenium Advance
        • Selenium Realtime
        • Framework
        • Selenium Interview
        • Selenium Videos
        • Selenium with Docker
      • Selenium with Python
      • WebdriverIO
        • Selenium Webdriver C# Tutorial
      • Cypress
      • Playwright
    • TestNG
    • Cucumber
    • Mobile Automation
      • Appium
    • API Testing
      • Postman
      • Rest Assured
      • SOAPUI
    • testRigor
    • Katalon
    • TestProject
    • Serenity BDD
    • Gradle- Build Tool
    • RPA-UiPath
    • Protractor
    • Windows Automation
  • Automation For Manual Testers
  • Services
  • Online Training
  • Contact us
  • About me
  • Follow us
    • Linkedin
    • Facebook Group
    • Facebook Page
    • Instagram

Automation

Selenium WebDriver tutorial Step by Step

You are here: Home / Uncategorized / How to perform Flash Testing with Selenium Webdriver

How to perform Flash Testing with Selenium Webdriver

March 15, 2015 by Mukesh Otwani 11 Comments

Flash Testing with Selenium

Hello, Welcome to Selenium Tutorials, In this post, we will see how to perform Flash testing with selenium.

Flash Testing with Selenium

If you ask me that do we have some plugin for this or some additional classes then my answer is no. We have to write separate code for this and we have to use the same. I have added a jar file in this post which contains the code already so you can directly use the same.

Partially we can do the same using Sikuli as well which is used for Game animation as well. This is mostly asked interview questions as well.

 

Sometime in your application, you may find some scenario where you need to check particular video as working as per expectation or not, to test this type of application we need to write some script to check the functionality of flash.

How to do Flash Testing with Selenium

We have some pre-defined method available for you tube flash application for example
1- pauseVideo
2- playVideo
3- mute, unmute etc.

so we will use some of these methods and try to explore the same

Note- in case your application use some other flash content please ask the developer to provide documentation of the same.

Precondition-
1- Download Flash jar – Click here

2- Download complete source code-Click here

3- Please read YouTube API. Methods- https://developers.google.com/youtube/flash_api_reference

 

Program for- Flash Testing with Selenium

package Flash;

import org.openqa.selenium.firefox.FirefoxDriver;

public class Testyoutube {

public static void main(String[] args) throws InterruptedException {

// Open firefox browser
FirefoxDriver driver = new FirefoxDriver();

// Maximize browser
driver.manage().window().maximize();

// FlashObjectWebDriver is seperate class which is available inside jar which we have    //attached
FlashObjectWebDriver flashApp = new FlashObjectWebDriver(driver, "movie_player");

// Pass the URL of video
driver.get("https://www.youtube.com/watch?v=7igozQAdBMs");
Thread.sleep(2000L);

// let the video load
while (Integer.parseInt(flashApp.callFlashObject("getPlayerState")) == 3){
Thread.sleep(1000L);
}

// Play the video for 10 seconds
Thread.sleep(10000);

// pause video using pauseVideo method
flashApp.callFlashObject("pauseVideo");

Thread.sleep(5000);

// play video using playVideo method
flashApp.callFlashObject("playVideo");
Thread.sleep(5000);

// Seek to is method which will forword video to 140 second
flashApp.callFlashObject("seekTo","140","true");

// Wait for 5 seconds
Thread.sleep(5000);

//mute video using playVideo method
flashApp.callFlashObject("mute");

// Wait for 5 seconds
Thread.sleep(5000);

//set the volume of  video using setVolume method
flashApp.callFlashObject("setVolume","50");

// wait for 5 seconds
Thread.sleep(5000);

}

}

 

Thanks for Visiting my blog. Please leave your comment below if you finding some issue.

Have a nice day 🙂

 

Filed Under: Uncategorized

Reader Interactions

Comments

  1. garima says

    August 31, 2016 at 4:45 PM

    Hi,
    Please see my test scenario below:
    I need to launch youtube or any application having embedded video. and need to test below things:
    1) Is video loaded
    2) Is video running
    3) are audio and video in sync
    4) volumne up and down
    5) All above scenarios by choosing full screen mode.

    Please help

    Reply
    • Mukesh Otwani says

      September 8, 2016 at 12:05 AM

      Hi garima,

      I am not that good in it 🙁 you can check youTube library may be you will get some methods for the same.

      Reply
  2. Rizvi says

    July 30, 2016 at 2:10 AM

    I m getting error document.pauseVideo is not a method
    Could you please help.me

    Reply
    • Mukesh Otwani says

      August 2, 2016 at 12:31 PM

      Hey Rizvi I think they have removed the method from the library. You can explore they must be having some different method name for this.

      Reply
  3. BG says

    April 23, 2016 at 3:40 AM

    I’m getting below error message while running the above code. I have used below URL:
    https://www.youtube.com/watch?v=qWp0pQlsJZc
    document.movie_player is undefined

    Reply
    • Mukesh Otwani says

      April 26, 2016 at 5:35 PM

      Please check youtube documents for new methods.

      Reply
  4. Prabhu says

    February 16, 2016 at 6:25 PM

    Hi Mukesh, Is it possible to fetch the data from flash object with ‘Object ID’.

    Reply
    • Mukesh Otwani says

      February 22, 2016 at 5:17 PM

      Hi Prabhu,

      No idea on this but I don’t think we can get from Flash object using Selenium.

      Reply
    • Khaja says

      April 19, 2016 at 7:40 PM

      No Prabhu, you cannot directly interact with flash Object ID. There are few work arounds to it, one that Mukesh mentioned in this post. The reason that you cannot interact with flash is that all of the flash elements are embedded into one Object html element, and those flash elements are closed files and enclosed in a container on a webpage. This literally means that the flash is embedded into your html (or DOM) as a single file. Selenium WebDriver do not have a direct capability to interact with such elements. So, the first work around is to ask the developers to expose the flash object methods, so that you can interact with Selenium WebDriver (or to be more precise with JavaScript, you can use the JavascriptExecutor if you have your framework written in Java). Now, this is quite a tedious process, but the best of the best solutions available as of this moment.

      The second way is to interact flash elements using mouse and keyboard combination using, Actions class. This can fail your scripts, if the x and y co-ordinates are not met. The same applies with the Robot class as well.

      The third, and second best solution is to use image recognition api like Sikuli. This is an evolving api, so you may have to explore more on this.

      I am trying to find, if Selenide (the selenium wrapper) has got any way of interacting with flash objects. If i find any, will let you know.

      Reply
  5. Raja says

    December 7, 2015 at 2:22 PM

    Thanks dude, for making others job easy..

    Reply
    • Mukesh Otwani says

      December 7, 2015 at 9:44 PM

      Thanks Raja 🙂

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Free Selenium Videos

https://www.youtube.com/watch?v=w_iPCT1ETO4

Search topic

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?

Stay connected via Facebook

Stay connected via Facebook

Archives

Footer

Categories

Recent Post

  • API Testing Using Postman And RestAssured
  • Disable Personalise Your Web Experience Microsoft Edge Prompt In Selenium
  • How To Fix Error: No tests found In Playwright
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Best and easy way to Group test cases in selenium

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?