Friday, March 4, 2016

Recording selenium test execution?

ATUTestRecorder recorder = new ATUTestRecorder("Directory","filename",false);
recorder.start();
recorder.stop();

Note: Download ATUTestRecorder_2.1.jar
https://drive.google.com/folderview?id=0B7rZvkq9tkwPRy1HLVJCdWtNekE&usp=sharing
 
(OR)
 
You need to download ScreenRecorder.jar file from Monte’s Home Page.
 
public class VideoRecorder extends ScreenRecorder {

    public static ScreenRecorder screenRecorder;
    public String name;

    public VideoRecorder(GraphicsConfiguration cfg, Rectangle captureArea, Format fileFormat, Format screenFormat,
            Format mouseFormat, Format audioFormat, File movieFolder, String name) throws IOException, AWTException {
        super(cfg, captureArea, fileFormat, screenFormat, mouseFormat, audioFormat, movieFolder);
        this.name = name;
    }

    @Override
    protected File createMovieFile(Format fileFormat) throws IOException {
        if (!movieFolder.exists()) {
            movieFolder.mkdirs();
        } else if (!movieFolder.isDirectory()) {
            throw new IOException("\"" + movieFolder + "\" is not a directory.");
        }
        return new File(movieFolder, name + "." + Registry.getInstance().getExtension(fileFormat));
    }

    public static void startRecord(String methodName) throws Exception {
        try {
            File file = new File(Constants.VIDEOS_DIR + File.separator);

            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            int width = screenSize.width;
            int height = screenSize.height;

            Rectangle captureSize = new Rectangle(0, 0, width, height);

            GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
                    .getDefaultConfiguration();

            screenRecorder = new VideoRecorder(gc, captureSize,
                    new Format(MediaTypeKey, MediaType.FILE, MimeTypeKey, MIME_AVI),
                    new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE,
                            CompressorNameKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE, DepthKey, 24, FrameRateKey,
                            Rational.valueOf(15), QualityKey, 1.0f, KeyFrameIntervalKey, 15 * 60),
                    new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, "black", FrameRateKey, Rational.valueOf(30)),
                    null, file, methodName);

            screenRecorder.start();

        } catch (Exception e) {
            throw new Exception(e.getMessage());
        }
    }

    public static void stopRecord() throws Exception {
        try {

            screenRecorder.stop();

        } catch (Exception e) {
            throw new Exception(e.getMessage());
        }
    }
}
 

No comments:

Post a Comment