title: how i can take a screenshot of a flash video while its playing using selenium webdriver?
body: <p>To automate the testing of videos, we decided to capture the screenshots of the video while its playing and compare those screenshots in order to ensure the video getting played. But when i am trying to capture the screenshots of the video player while video is getting played, only the black screen is getting displayed.</p>
  <p>We are using selenium web-driver and JAVA for developing the automation scripts. Is there any other way that we can ensure the videos are getting played or not. Is there any flash support needed for taking screenshots of a flash video getting played?</p>
  <p>Please help us with this. Is the method we following the correct one for video testing?</p>
  <p>Please find my below selenium web-driver code</p>
  <h2>CODE</h2>
  <pre><code>import java.io.File;
  import java.io.IOException;
  import org.apache.commons.io.FileUtils;
  import org.openqa.selenium.By;
  import org.openqa.selenium.OutputType;
  import org.openqa.selenium.TakesScreenshot;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebDriverException;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.firefox.FirefoxDriver;
       
  public class Screenshot {
  
  public static void main(String[] args) throws InterruptedException, IOException
  {
      FirefoxDriver driver = new FirefoxDriver();
      driver.manage().window().maximize();
      FlashObjectWebDriver flashapp=null;
      flashapp = new FlashObjectWebDriver(driver,&quot;PlayerPlatformAPI&quot;);
      driver.get(&quot;Flash media player URL&quot;);
      Thread.sleep(1000L);
      WebElement streamurl = driver.findElement(By.name(&quot;Stream URL&quot;));
      streamurl.clear();
      streamurl.sendKeys(&quot;video link&quot;);
      WebElement    tune=driver.findElement(By.xpath(&quot;//div[@id='outer']//input[@type='button']&quot;));
      tune.click();
      Thread.sleep(1000L);
      driver.findElement(By.id(&quot;PlayerPlatformAPI&quot;));
      screen.seekTo(50);
      flashapp.callFlashObject(&quot;SeekTo&quot;,&quot;50&quot;);
      int i;
      for(i=0;i&lt;4;i++)
      {
      File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
      // Now you can do whatever you need to do with it, for example copy somewhere
      File file1 = new File(&quot;c:\\tmp\\&quot;+i+&quot;_scrnshot.jpeg&quot;);
      FileUtils.copyFile(scrFile,file1);
      Thread.sleep(10000);
      }
      driver.close();
  }
  }
  </code></pre>