1

I want to extract the last frame from the swf file using Java. However, after trying several ways to to do that, one way it worked is by using selenium to launch a browser, load the swf, wait for the last frame and take the snapshot. It works fine on my mac. The code is as below

package flash;

import java.io.File;

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class snaphot_swf {

    public static void main(String[] args) throws Exception{
        // TODO Auto-generated method stub
        WebDriver driver = new FirefoxDriver();
        driver.get("file:///Users/test/Downloads/Car-speakers-590x90.swf");
        Thread.sleep(10000);
        File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
        // Now you can do whatever you need to do with it, for example copy somewhere
        FileUtils.copyFile(scrFile, new File("/Users/test/Documents/screenshots/screenshot.png"));
        driver.close();
        System.out.print("snapshot taken");
    }

}

I now want to do the same on a head less browser in Cent OS 6.4

I did the following:

//install firefox
    yum install firefox

//install flash plugin
    rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-x86_64-1.0-1.noarch.rpm
    rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux

    yum check-update

    yum install flash-plugin nspluginwrapper alsa-plugins-pulseaudio libcurl

//install Xvfb
yum info xorg-x11-server-Xvfb

//starting Xvfb
/usr/bin/Xvfb :1 -screen 0 1024x768x24 &
export DISPLAY=:1 

Now, when I run my Java code for a png file by loading it in the firefox browser and taking snapshot, it works perfectly well. However, when I try to load the swf file I get a blank snapshot.

How can I load the swf in Firefox and obtain a snapshot

kosta
  • 4,302
  • 10
  • 50
  • 104

0 Answers0